Java Code Examples for java.awt.FileDialog#LOAD
The following examples show how to use
java.awt.FileDialog#LOAD .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GtkFileDialogPeer.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private void showNativeDialog() { String dirname = fd.getDirectory(); // File path has a priority against directory path. String filename = fd.getFile(); if (filename != null) { final File file = new File(filename); if (fd.getMode() == FileDialog.LOAD && dirname != null && file.getParent() == null) { // File path for gtk_file_chooser_set_filename. filename = dirname + (dirname.endsWith(File.separator) ? "" : File.separator) + filename; } if (fd.getMode() == FileDialog.SAVE && file.getParent() != null) { // Filename for gtk_file_chooser_set_current_name. filename = file.getName(); // Directory path for gtk_file_chooser_set_current_folder. dirname = file.getParent(); } } run(fd.getTitle(), fd.getMode(), dirname, filename, fd.getFilenameFilter(), fd.isMultipleMode(), fd.getX(), fd.getY()); }
Example 2
Source File: GtkFileDialogPeer.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private void showNativeDialog() { String dirname = fd.getDirectory(); // File path has a priority against directory path. String filename = fd.getFile(); if (filename != null) { final File file = new File(filename); if (fd.getMode() == FileDialog.LOAD && dirname != null && file.getParent() == null) { // File path for gtk_file_chooser_set_filename. filename = dirname + (dirname.endsWith(File.separator) ? "" : File.separator) + filename; } if (fd.getMode() == FileDialog.SAVE && file.getParent() != null) { // Filename for gtk_file_chooser_set_current_name. filename = file.getName(); // Directory path for gtk_file_chooser_set_current_folder. dirname = file.getParent(); } } GtkFileDialogPeer.this.run(fd.getTitle(), fd.getMode(), dirname, filename, fd.getFilenameFilter(), fd.isMultipleMode(), fd.getX(), fd.getY()); }
Example 3
Source File: GtkFileDialogPeer.java From hottub with GNU General Public License v2.0 | 6 votes |
private void showNativeDialog() { String dirname = fd.getDirectory(); // File path has a priority against directory path. String filename = fd.getFile(); if (filename != null) { final File file = new File(filename); if (fd.getMode() == FileDialog.LOAD && dirname != null && file.getParent() == null) { // File path for gtk_file_chooser_set_filename. filename = dirname + (dirname.endsWith(File.separator) ? "" : File.separator) + filename; } if (fd.getMode() == FileDialog.SAVE && file.getParent() != null) { // Filename for gtk_file_chooser_set_current_name. filename = file.getName(); // Directory path for gtk_file_chooser_set_current_folder. dirname = file.getParent(); } } run(fd.getTitle(), fd.getMode(), dirname, filename, fd.getFilenameFilter(), fd.isMultipleMode(), fd.getX(), fd.getY()); }
Example 4
Source File: GtkFileDialogPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private void showNativeDialog() { String dirname = fd.getDirectory(); // File path has a priority against directory path. String filename = fd.getFile(); if (filename != null) { final File file = new File(filename); if (fd.getMode() == FileDialog.LOAD && dirname != null && file.getParent() == null) { // File path for gtk_file_chooser_set_filename. filename = dirname + (dirname.endsWith(File.separator) ? "" : File.separator) + filename; } if (fd.getMode() == FileDialog.SAVE && file.getParent() != null) { // Filename for gtk_file_chooser_set_current_name. filename = file.getName(); // Directory path for gtk_file_chooser_set_current_folder. dirname = file.getParent(); } } run(fd.getTitle(), fd.getMode(), dirname, filename, fd.getFilenameFilter(), fd.isMultipleMode(), fd.getX(), fd.getY()); }
Example 5
Source File: GtkFileDialogPeer.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private void showNativeDialog() { String dirname = fd.getDirectory(); // File path has a priority against directory path. String filename = fd.getFile(); if (filename != null) { final File file = new File(filename); if (fd.getMode() == FileDialog.LOAD && dirname != null && file.getParent() == null) { // File path for gtk_file_chooser_set_filename. filename = dirname + (dirname.endsWith(File.separator) ? "" : File.separator) + filename; } if (fd.getMode() == FileDialog.SAVE && file.getParent() != null) { // Filename for gtk_file_chooser_set_current_name. filename = file.getName(); // Directory path for gtk_file_chooser_set_current_folder. dirname = file.getParent(); } } if (!quit) { run(fd.getTitle(), fd.getMode(), dirname, filename, fd.getFilenameFilter(), fd.isMultipleMode(), fd.getX(), fd.getY()); } }
Example 6
Source File: GtkFileDialogPeer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
private void showNativeDialog() { String dirname = fd.getDirectory(); // File path has a priority against directory path. String filename = fd.getFile(); if (filename != null) { final File file = new File(filename); if (fd.getMode() == FileDialog.LOAD && dirname != null && file.getParent() == null) { // File path for gtk_file_chooser_set_filename. filename = dirname + (dirname.endsWith(File.separator) ? "" : File.separator) + filename; } if (fd.getMode() == FileDialog.SAVE && file.getParent() != null) { // Filename for gtk_file_chooser_set_current_name. filename = file.getName(); // Directory path for gtk_file_chooser_set_current_folder. dirname = file.getParent(); } } run(fd.getTitle(), fd.getMode(), dirname, filename, fd.getFilenameFilter(), fd.isMultipleMode(), fd.getX(), fd.getY()); }
Example 7
Source File: GtkFileDialogPeer.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private void showNativeDialog() { String dirname = fd.getDirectory(); // File path has a priority against directory path. String filename = fd.getFile(); if (filename != null) { final File file = new File(filename); if (fd.getMode() == FileDialog.LOAD && dirname != null && file.getParent() == null) { // File path for gtk_file_chooser_set_filename. filename = dirname + (dirname.endsWith(File.separator) ? "" : File.separator) + filename; } if (fd.getMode() == FileDialog.SAVE && file.getParent() != null) { // Filename for gtk_file_chooser_set_current_name. filename = file.getName(); // Directory path for gtk_file_chooser_set_current_folder. dirname = file.getParent(); } } run(fd.getTitle(), fd.getMode(), dirname, filename, fd.getFilenameFilter(), fd.isMultipleMode(), fd.getX(), fd.getY()); }
Example 8
Source File: GtkFileDialogPeer.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private void showNativeDialog() { String dirname = fd.getDirectory(); // File path has a priority against directory path. String filename = fd.getFile(); if (filename != null) { final File file = new File(filename); if (fd.getMode() == FileDialog.LOAD && dirname != null && file.getParent() == null) { // File path for gtk_file_chooser_set_filename. filename = dirname + (dirname.endsWith(File.separator) ? "" : File.separator) + filename; } if (fd.getMode() == FileDialog.SAVE && file.getParent() != null) { // Filename for gtk_file_chooser_set_current_name. filename = file.getName(); // Directory path for gtk_file_chooser_set_current_folder. dirname = file.getParent(); } } run(fd.getTitle(), fd.getMode(), dirname, filename, fd.getFilenameFilter(), fd.isMultipleMode(), fd.getX(), fd.getY()); }
Example 9
Source File: Ted.java From netbeans with Apache License 2.0 | 5 votes |
/** This method is called when File -> Open menu item is invoked. * It displays a dialog to choose the file to be opened and edited. * @param evt ActionEvent instance passed from actionPerformed event. */ private void openMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openMenuItemActionPerformed FileDialog fileDialog = new FileDialog(this, "Open...", FileDialog.LOAD); fileDialog.show(); if (fileDialog.getFile() == null) return; fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile(); FileInputStream fis = null; String str = null; try { fis = new FileInputStream(fileName); int size = fis.available(); byte[] bytes = new byte [size]; fis.read(bytes); str = new String(bytes); } catch (IOException e) { } finally { try { fis.close(); } catch (IOException e2) { } } if (str != null) textBox.setText(str); }
Example 10
Source File: GSPNAnalysis.java From PIPE with MIT License | 5 votes |
/** * Main method for running this externally without PIPE * * @param args command line arguments */ public static void main(String[] args) { JFrame frame = new JFrame("Steady state results"); FileDialog selector = new FileDialog(frame, "Select petri net", FileDialog.LOAD); frame.setContentPane(new GSPNAnalysis(selector).mainPanel); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
Example 11
Source File: StateSpaceModule.java From PIPE with MIT License | 5 votes |
@Override public void start(PetriNet petriNet) { JFrame frame = new JFrame("State Space Explorer"); FileDialog selector = new FileDialog(frame, "Select petri net", FileDialog.LOAD); FileDialog saver = new FileDialog(frame, "Save binary transition data", FileDialog.SAVE); frame.setContentPane(new ReachabilityGraph(selector, petriNet).getMainPanel()); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.pack(); frame.setVisible(true); }
Example 12
Source File: FileChooser.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * * * @param title * @param mode * @param filter * * @return */ private static File chooseFileAWT(String title, Mode mode, FileFilter filter) { Easik e = Easik.getInstance(); EasikSettings s = e.getSettings(); FileDialog dialog = new FileDialog(e.getFrame(), title, (mode == Mode.SAVE) ? FileDialog.SAVE : FileDialog.LOAD); dialog.setDirectory(s.getDefaultFolder()); if ((mode == Mode.DIRECTORY) && EasikConstants.RUNNING_ON_MAC) { System.setProperty("apple.awt.fileDialogForDirectories", "true"); } else if (filter != null) { dialog.setFilenameFilter(filter); } // Show the dialog (this blocks until the user is done) dialog.setVisible(true); if ((mode == Mode.DIRECTORY) && EasikConstants.RUNNING_ON_MAC) { System.setProperty("apple.awt.fileDialogForDirectories", "false"); } String filename = dialog.getFile(); if (filename == null) { return null; } File selected = new File(dialog.getDirectory(), filename); if (mode != Mode.DIRECTORY) { s.setProperty("folder_last", selected.getParentFile().getAbsolutePath()); } return selected; }
Example 13
Source File: ReachabilityGraph.java From PIPE with MIT License | 5 votes |
/** * Main method for running this externally without PIPE * * @param args command line arguments */ public static void main(String[] args) { JFrame frame = new JFrame("ReachabilityGraph"); FileDialog selector = new FileDialog(frame, "Select petri net", FileDialog.LOAD); frame.setContentPane(new ReachabilityGraph(selector).panel1); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
Example 14
Source File: MainGui.java From OpenID-Attacker with GNU General Public License v2.0 | 5 votes |
private void loadItemActionPerformed(ActionEvent evt) {//GEN-FIRST:event_loadItemActionPerformed FileDialog fd = new FileDialog(this, "Choose a file", FileDialog.LOAD); fd.setFile("*.xml"); fd.setVisible(true); File[] files = fd.getFiles(); if (files.length > 0) { File loadFile = files[0]; try { ToolConfiguration currentToolConfig = new ToolConfiguration(); currentToolConfig.setAttackerConfig(controller.getAttackerConfig()); currentToolConfig.setAnalyzerConfig(controller.getAnalyzerConfig()); XmlPersistenceHelper.mergeConfigFileToConfigObject(loadFile, currentToolConfig); } catch (XmlPersistenceError ex) { Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex); } } /*int returnVal = loadFileChooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File loadFile = loadFileChooser.getSelectedFile(); try { XmlPersistenceHelper.mergeConfigFileToConfigObject(loadFile, controller.getConfig()); } catch (XmlPersistenceError ex) { Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex); } }*/ }
Example 15
Source File: CustomSettingsDialog.java From swingsane with Apache License 2.0 | 5 votes |
private File getLoadFile(String filename, String extension) { FileDialog fd = new FileDialog((JDialog) getRootPane().getTopLevelAncestor(), Localizer.localize("LoadScannerOptionsFromFileTitle"), FileDialog.LOAD); fd.setDirectory("."); FilenameExtensionFilter filter = new FilenameExtensionFilter(); filter.addExtension("xml"); fd.setFilenameFilter(filter); fd.setModal(true); fd.setVisible(true); if (fd.getFile() == null) { return null; } return new File(fd.getDirectory() + File.separator + fd.getFile()); }
Example 16
Source File: Notate.java From jmg with GNU General Public License v2.0 | 5 votes |
/** * Dialog to import a jm file */ public void openJM() { FileDialog loadjm = new FileDialog(this, "Select a jm score file.", FileDialog.LOAD); loadjm.setDirectory( lastDirectory ); loadjm.show(); String fileName = loadjm.getFile(); if (fileName != null) { Score s = new Score(); lastDirectory = loadjm.getDirectory(); Read.jm(s, lastDirectory + fileName); setNewScore(s); } }
Example 17
Source File: Read.java From jmg with GNU General Public License v2.0 | 5 votes |
/** * Import to a jMusic score a standard MIDI file * Assume the MIDI file name is the same as the score title with .mid appended * prompt for a fileName * @param Score */ public static void midi(Score score) { FileDialog fd = new FileDialog(new Frame(), "Select a MIDI file to open.", FileDialog.LOAD); fd.show(); if (fd.getFile() != null) { Read.midi(score, fd.getDirectory() + fd.getFile()); } }
Example 18
Source File: rtest.java From RDMP1 with GNU General Public License v2.0 | 5 votes |
public String rChooseFile(Rengine re, int newFile) { FileDialog fd = new FileDialog(new Frame(), (newFile == 0) ? "Select a file" : "Select a new file", (newFile == 0) ? FileDialog.LOAD : FileDialog.SAVE); fd.show(); String res = null; if (fd.getDirectory() != null) res = fd.getDirectory(); if (fd.getFile() != null) res = (res == null) ? fd.getFile() : (res + fd.getFile()); return res; }
Example 19
Source File: REngineManager.java From gsn with GNU General Public License v3.0 | 5 votes |
public String rChooseFile(Rengine re, int newFile) { FileDialog fd = new FileDialog(new Frame(), (newFile==0)?"Select a file":"Select a new file", (newFile==0)?FileDialog.LOAD:FileDialog.SAVE); fd.setVisible(true); String res=null; if (fd.getDirectory()!=null) res=fd.getDirectory(); if (fd.getFile()!=null) res=(res==null)?fd.getFile():(res+fd.getFile()); return res; }
Example 20
Source File: SparkTransferManager.java From Spark with Apache License 2.0 | 2 votes |
/** * Return the File Chooser to user. * @param parent the parent component. * @param title the title. * @return the FileChooser. (Native Widget) */ public FileDialog getFileChooser(Frame parent, String title) { return new FileDialog(parent, title, FileDialog.LOAD); }