4 import ij.plugin.frame.Recorder;
9 import javax.swing.filechooser.*;
17 private boolean recordPath;
18 private static String defaultDirectory;
19 private static Frame sharedFrame;
27 if (path==null || path.equals(
"")) {
29 if (name!=null) defaultDirectory = dir;
40 public OpenDialog(String title, String defaultDir, String defaultName) {
45 jOpen(title, defaultDir, defaultName);
52 void jOpen(String title, String path, String fileName) {
54 JFileChooser fc =
new JFileChooser();
57 fdir =
new File(path);
59 fc.setCurrentDirectory(fdir);
61 fc.setSelectedFile(
new File(fileName));
62 int returnVal = fc.showOpenDialog(null);
63 if (returnVal!=JFileChooser.APPROVE_OPTION)
65 File file = fc.getSelectedFile();
68 name = file.getName();
69 dir = fc.getCurrentDirectory().getPath()+File.separator;
73 void decodePath(String path) {
74 int i = path.lastIndexOf(
'/');
76 i = path.lastIndexOf(
'\\');
78 dir = path.substring(0, i+1);
79 name = path.substring(i+1);
94 Recorder.recordPath(title, dir+name);
100 if (defaultDirectory==null)
102 return defaultDirectory;
105 public static void setDefaultDirectory(String defaultDir) {
106 defaultDirectory = defaultDir;