List of usage examples for javax.swing JFileChooser showDialog
@SuppressWarnings("deprecation") public int showDialog(Component parent, String approveButtonText) throws HeadlessException
From source file:org.ut.biolab.medsavant.client.view.dialog.SavantExportForm.java
private void chooseFileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseFileButtonActionPerformed JFileChooser fc = new JFileChooser(); fc.setDialogTitle("Save Savant Project"); fc.setDialogType(JFileChooser.SAVE_DIALOG); fc.addChoosableFileFilter(new ExtensionsFileFilter(new String[] { "svp" })); fc.setMultiSelectionEnabled(false);/*from w w w . j a va 2s .co m*/ int result = fc.showDialog(null, null); if (result == JFileChooser.CANCEL_OPTION || result == JFileChooser.ERROR_OPTION) { return; } outputFile = fc.getSelectedFile(); String path = outputFile.getAbsolutePath(); outputFileField.setText(path); exportButton.setEnabled(true); }
From source file:plugin.notes.gui.NotesView.java
/** * obtains an Image for input using a custom JFileChooser dialog * *@param startDir Directory to open JFielChooser to *@param exts Extensions to search for *@param desc Description for files *@return File pointing to the selected image *//*from w w w . j ava 2 s . com*/ private File getImageFromChooser(String startDir, String[] exts, String desc) { JFileChooser jImageDialog = new JFileChooser(); jImageDialog.setCurrentDirectory(new File(startDir)); jImageDialog.setAccessory(new ImageFileChooserPreview(jImageDialog)); jImageDialog.setDialogType(JFileChooser.CUSTOM_DIALOG); jImageDialog.setFileFilter(new FileNameExtensionFilter(desc, exts)); jImageDialog.setDialogTitle("Select an Image to Insert"); int optionSelected = jImageDialog.showDialog(this, "Insert"); if (optionSelected == JFileChooser.APPROVE_OPTION) { return jImageDialog.getSelectedFile(); } return null; }
From source file:plugins.tprovoost.Microscopy.MicroManagerForIcy.MMMainFrame.java
/** * Used to load XML Files//from w ww . ja v a 2s .c o m * * @return Returns null if Dialog exited. */ private String xmlFileChooser() { String filename = null; JFileChooser fc = new JFileChooser(); fc.setFileFilter(new FileNameExtensionFilter("Sate Files (.xml)", "xml")); int returnVal = fc.showDialog(Icy.getMainInterface().getMainFrame(), "Save File"); if (returnVal == JFileChooser.APPROVE_OPTION) { filename = fc.getSelectedFile().getAbsolutePath(); if (!filename.endsWith(".xml")) filename += ".xml"; } else { filename = null; } return filename; }