21import java.awt.Component;
23import java.util.HashSet;
26import javax.swing.JFileChooser;
27import javax.swing.JTextField;
28import javax.swing.filechooser.FileNameExtensionFilter;
29import javax.swing.filechooser.FileSystemView;
43 File startFile =
new File(System.getProperty(
"user.dir"));
44 while (!FileSystemView.getFileSystemView().isFileSystemRoot(startFile))
46 startFile = startFile.getParentFile();
55 fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
58 if (
fileChooser.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION)
62 fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
73 txtField.setText(file.getAbsolutePath());
84 fileChooser.setDialogTitle(
"Select one or more files");
85 Set<File> files =
null;
86 if (
fileChooser.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION)
88 files =
new HashSet<File>();
90 for (
int i=0; i<arr.length; i++)
107 fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
109 if (
fileChooser.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION)
123 FileNameExtensionFilter jsonFilter =
new FileNameExtensionFilter(
126 FileNameExtensionFilter sdfFilter =
new FileNameExtensionFilter(
130 fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
132 if (
fileChooser.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION)
148 txtField.setText(file.getAbsolutePath());
157 fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
159 fileChooser.setDialogTitle(
"Choose Folder to Load");
161 if (
fileChooser.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION)
165 fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
176 if (
fileChooser.showSaveDialog(parent) == JFileChooser.APPROVE_OPTION)
File opener for DENOPTIM GUI.
static File pickFolderForTxtField(JTextField txtField, Component parent)
static File pickFolder(Component parent)
static JFileChooser fileChooser
static Set< File > pickManyFiles(Component parent)
static File pickFileWithGraph(Component parent)
static File getSystemRoot()
static File pickFile(Component parent)
static File pickFileOrFolder(Component parent)
static File pickFileForSaving(Component parent)
static File pickFileForTxtField(JTextField txtField, Component parent)