import java.io.File;
import javax.swing.*;
import javax.swing.border.*;
+import javax.swing.filechooser.*;
import javax.swing.text.*;
class Dialog extends JDialog implements ActionListener,
return width + gap;
}
- public static File showChooser(String title, File defFile, Container c) {
+ public static File showChooser(String title, File defFile,
+ Container c, FileNameExtensionFilter f) {
JFileChooser fc = new JFileChooser(defFile);
fc.setDialogTitle(title);
fc.setApproveButtonText("OK \u21B5");
fc.setFileHidingEnabled(false);
+ if (f != null)
+ fc.setFileFilter(f);
if (fc.showOpenDialog(c) == JFileChooser.APPROVE_OPTION)
return fc.getSelectedFile();
else
return null;
}
+ public static File showChooser(String title, File defFile, Container c) {
+ return showChooser(title, defFile, c, null);
+ }
+
+ protected File showChooser(String title, File defFile,
+ FileNameExtensionFilter f) {
+ return showChooser(title, defFile, this, f);
+ }
+
protected File showChooser(String title, File defFile) {
return showChooser(title, defFile, this);
}
import java.awt.Cursor;
import java.awt.event.*;
import java.io.File;
+import javax.swing.filechooser.*;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JDialog;
import javax.swing.JFrame;
File dflt = new File(FileUtils.getVncHomeDir().concat("default.tigervnc"));
if (!dflt.exists() || !dflt.isFile())
dflt = new File(FileUtils.getVncHomeDir());
- File f = Dialog.showChooser(title, dflt, this);
+ FileNameExtensionFilter filter =
+ new FileNameExtensionFilter("TigerVNC configuration (*.tigervnc)", "tigervnc");
+ File f = Dialog.showChooser(title, dflt, this, filter);
while (f != null && f.exists() && f.isFile()) {
String msg = f.getAbsolutePath();
msg = msg.concat(" already exists. Do you want to overwrite?");
if (op.getValue() == options[0])
break;
else
- f = Dialog.showChooser(title, f, this);
+ f = Dialog.showChooser(title, f, this, filter);
}
if (f != null && (!f.exists() || f.canWrite()))
saveViewerParameters(f.getAbsolutePath(), vncServerName.getValue());
import java.text.NumberFormat;
import javax.swing.*;
import javax.swing.border.*;
+import javax.swing.filechooser.*;
import javax.swing.UIManager.*;
import javax.swing.text.*;
import java.util.*;
public void actionPerformed(ActionEvent e) {
JComponent c = ((JButton)e.getSource()).getRootPane();
File dflt = new File(CSecurityTLS.X509CA.getValueStr());
- File f = showChooser("Path to X509 CA certificate", dflt, c);
+ FileNameExtensionFilter filter =
+ new FileNameExtensionFilter("X.509 certificate", "crt", "cer", "pem");
+ File f = showChooser("Path to X509 CA certificate", dflt, c, filter);
if (f != null && f.exists() && f.canRead())
caInput.setText(f.getAbsolutePath());
}
public void actionPerformed(ActionEvent e) {
JComponent c = ((JButton)e.getSource()).getRootPane();
File dflt = new File(CSecurityTLS.X509CRL.getValueStr());
- File f = showChooser("Path to X509 CRL file", dflt, c);
+ FileNameExtensionFilter filter =
+ new FileNameExtensionFilter("X.509 CRL", "crl");
+ File f = showChooser("Path to X509 CRL file", dflt, c, filter);
if (f != null && f.exists() && f.canRead())
crlInput.setText(f.getAbsolutePath());
}
import java.io.File;
import javax.swing.*;
import javax.swing.border.*;
+import javax.swing.filechooser.*;
import javax.swing.WindowConstants.*;
import java.util.*;
private void handleLoad() {
String title = "Select a TigerVNC configuration file";
File dflt = new File(FileUtils.getVncHomeDir().concat("default.tigervnc"));
- File f = showChooser(title, dflt);
+ FileNameExtensionFilter filter =
+ new FileNameExtensionFilter("TigerVNC configuration (*.tigervnc)", "tigervnc");
+ File f = showChooser(title, dflt, filter);
if (f != null && f.exists() && f.canRead())
loadViewerParameters(f.getAbsolutePath());
}
File dflt = new File(FileUtils.getVncHomeDir().concat("default.tigervnc"));
if (!dflt.exists() || !dflt.isFile())
dflt = new File(FileUtils.getVncHomeDir());
- File f = showChooser(title, dflt);
+ FileNameExtensionFilter filter =
+ new FileNameExtensionFilter("TigerVNC configuration (*.tigervnc)", "tigervnc");
+ File f = showChooser(title, dflt, filter);
while (f != null && f.exists() && f.isFile()) {
String msg = f.getAbsolutePath();
msg = msg.concat(" already exists. Do you want to overwrite?");
if (op.getValue() == options[0])
break;
else
- f = showChooser(title, f);
+ f = showChooser(title, f, filter);
}
if (f != null && (!f.exists() || f.canWrite()))
saveViewerParameters(f.getAbsolutePath(), (String)server.getSelectedItem());