List of utility methods to do JFileChooser
String | openFile() open File JFileChooser fc = null; fc = new JFileChooser(System.getProperty("user.home")); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = fc.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); if (file.getPath().equals("")) return null; ... |
String | openFile(String fileExtension) open File JFileChooser dlgFile = new JFileChooser(); dlgFile.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); dlgFile.setApproveButtonText("Open"); int returnVal = dlgFile.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = dlgFile.getSelectedFile(); return file.getAbsolutePath(); return ""; |
File | promptFile(File file, FileFilter filter, String title) Checks if the specified file exists. if (file == null || !file.exists()) { File start = file.getParentFile(); if (!start.exists()) { start = new File("."); JFileChooser chooser = new JFileChooser(start); if (title != null) { chooser.setDialogTitle(title); ... |
File | promptForFilename(String title) Display the showSaveDialog which allows the user to specify file and directory File file = null; String _title = "Arrah Technology Save File"; if (title != null || "".equals(title) == false) _title = title; JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle(_title); chooser.setCurrentDirectory(new File(".")); int returnVal = chooser.showSaveDialog(null); ... |
String | PromptForFileOpen(Component c) Prompt For File Open JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fc.setCurrentDirectory(new File(".//Patches//")); int returnVal = fc.showOpenDialog(c); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); return fc.getCurrentDirectory() + "\\" + file.getName(); } else { ... |
File | promptSaveJFileChooser(String suggestedFileName, FileNameExtensionFilter... fileNameExtensionFilters) prompt Save J File Chooser return null;
|
String | readAsString(File file) read As String return readAsString(file.toPath());
|
String | readAsString(File file) read As String return readAsString(file.toPath());
|
double[][] | readFromFile() read matrix written as atext file with ; split token return readFromFile(getFileFromChooserLoad(getDefaultDirectory()).getAbsolutePath(), ";"); |
void | removeChoosableFileFilters(JFileChooser fc) remove Choosable File Filters FileFilter[] filters = fc.getChoosableFileFilters(); for (int i = 0; i < filters.length; i++) { fc.removeChoosableFileFilter(filters[i]); return; |