Java Code Examples for javax.swing.JFileChooser#setDialogTitle()

The following examples show how to use javax.swing.JFileChooser#setDialogTitle() . 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: AndroidProjectTemplatePanelVisualBasicSettings.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
    String command = evt.getActionCommand();
    if ("BROWSE".equals(command)) {
        JFileChooser chooser = new JFileChooser();
        FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
        chooser.setDialogTitle("Select Project Location");
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        String path = this.projectLocationTextField.getText();
        if (path.length() > 0) {
            File f = new File(path);
            if (f.exists()) {
                chooser.setSelectedFile(f);
            }
        }
        if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
            File projectDir = chooser.getSelectedFile();
            projectLocationTextField.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
        }
        panel.fireChangeEvent();
    }

}
 
Example 2
Source File: PanelProjectLocationVisual.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void browseLocationAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseLocationAction
    String command = evt.getActionCommand();
    
    if ("BROWSE".equals(command)) { //NOI18N
        JFileChooser chooser = new JFileChooser();
        chooser.setDialogTitle(NbBundle.getMessage(PanelProjectLocationVisual.class,"LBL_NWP1_SelectProjectLocation")); //NOI18N
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        String path = projectLocationTextField.getText();
        if (path.length() > 0) {
            File f = new File(path);
            if (f.exists())
                chooser.setSelectedFile(f);
        }
        if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
            File projectDir = chooser.getSelectedFile();
            projectLocationTextField.setText(projectDir.getAbsolutePath());
        }            
        panel.fireChangeEvent();
    }
}
 
Example 3
Source File: PanelProjectLocationVisual.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void browseLocationJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseLocationJButtonActionPerformed
            JFileChooser chooser = new JFileChooser ();
            FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
            chooser.setDialogTitle(NbBundle.getMessage(PanelProjectLocationVisual.class,"GetProjectLocationPanel.FileChooserTitle"));
            chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
            String path = projectLocationTextField.getText().trim();
            if (path.length() > 0) {
                File f = new File (path);
                if (f.exists ()) {
                    chooser.setSelectedFile(f);
                }
            }
            if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(SwingUtilities.getWindowAncestor(this))) { //NOI18N
                File projectDir = chooser.getSelectedFile();
                projectLocationTextField.setText( projectDir.getAbsolutePath() );
            }   
}
 
Example 4
Source File: FilePropertyEditor.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
protected void selectFile() {
  ResourceManager rm = ResourceManager.all(FilePropertyEditor.class);

  JFileChooser chooser = UserPreferences.getDefaultFileChooser();
  chooser.setDialogTitle(rm.getString("FilePropertyEditor.dialogTitle"));
  chooser.setApproveButtonText(
    rm.getString("FilePropertyEditor.approveButtonText"));
  chooser.setApproveButtonMnemonic(
    rm.getChar("FilePropertyEditor.approveButtonMnemonic"));
  customizeFileChooser(chooser);
  
  if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(editor)) {
    File oldFile = (File)getValue();
    File newFile = chooser.getSelectedFile();
    String text = newFile.getAbsolutePath();
    textfield.setText(text);
    firePropertyChange(oldFile, newFile);
  }
}
 
Example 5
Source File: InteractiveTerm.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Performs the process of loading a simulation.
 * 
 * return true if a sim is loaded
 */
public boolean loadSimulationProcess() {
	sim.stop();

	String dir = Simulation.SAVE_DIR;;
	String title = Msg.getString("MainWindow.dialogLoadSavedSim");

	JFileChooser chooser = new JFileChooser(dir);
	chooser.setDialogTitle(title); // $NON-NLS-1$
	if (chooser.showOpenDialog(marsTerminal.getFrame()) == JFileChooser.APPROVE_OPTION) {
		sim.loadSimulation(chooser.getSelectedFile());
		return true;
	}
	
	return false;
}
 
Example 6
Source File: ProjectAttributesPanelVisual.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Messages("TIT_Select_Project_Location=Select Project Location")
private void btBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btBrowseActionPerformed
    if ("BROWSE".equals(evt.getActionCommand())) { //NOI18N
        JFileChooser chooser = new JFileChooser();
        chooser.setCurrentDirectory(null);
        chooser.setDialogTitle(Bundle.TIT_Select_Project_Location());
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        String path = tfProjectLocation.getText();
        if (path.length() > 0) {
            File f = new File(path);
            if (f.exists()) {
                chooser.setSelectedFile(f);
            }
        }
        if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
            File projectDir = chooser.getSelectedFile();
            tfProjectLocation.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
        }

    }
}
 
Example 7
Source File: pluggableViewDemoSuitePanelVisual.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
    String command = evt.getActionCommand();
    if ("BROWSE".equals(command)) {
        JFileChooser chooser = new JFileChooser();
        FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
        chooser.setDialogTitle("Select Project Location");
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        String path = this.projectLocationTextField.getText();
        if (path.length() > 0) {
            File f = new File(path);
            if (f.exists()) {
                chooser.setSelectedFile(f);
            }
        }
        if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
            File projectDir = chooser.getSelectedFile();
            projectLocationTextField.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
        }
        panel.fireChangeEvent();
    }

}
 
Example 8
Source File: GUI.java    From smsbackupreader with GNU General Public License v3.0 6 votes vote down vote up
private void exportAllAction() {
	if (!(fileLocationField.getText().equals("...")) && (contactListBox.isEnabled())) {
		saveChooser = new JFileChooser();
		saveChooser.setDialogTitle("Choose a file to save as...");
		saveChooser.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG);
		saveChooser.setSelectedFile(new java.io.File("SMS_Export.txt"));

		int returnValue = saveChooser.showSaveDialog(frmSmsBackupReader);
		if (returnValue == JFileChooser.APPROVE_OPTION) {
			File saveFile = saveChooser.getSelectedFile();
			String tempLocation = saveFile.getAbsolutePath();
			exportFileField.setText(tempLocation);

			if(reader.exportAllMessages(saveFile)) {
				JOptionPane.showMessageDialog(frmSmsBackupReader, "All messages exported successfully!");
			}
			else {
				JOptionPane.showMessageDialog(frmSmsBackupReader, "Failed to export all messages!");
			}
		}
	}
	else {
		JOptionPane.showMessageDialog(frmSmsBackupReader, "Load messages first!");
	}
}
 
Example 9
Source File: DOptions.java    From portecle with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Browse button pressed or otherwise activated. Allow the user to choose a CA certs file.
 */
private void browsePressed()
{
	JFileChooser chooser = FileChooserFactory.getKeyStoreFileChooser(null);

	if (m_fCaCertsFile.getParentFile().exists())
	{
		chooser.setCurrentDirectory(m_fCaCertsFile.getParentFile());
	}

	chooser.setDialogTitle(RB.getString("DOptions.ChooseCACertsKeyStore.Title"));

	chooser.setMultiSelectionEnabled(false);

	int iRtnValue = chooser.showDialog(this, RB.getString("DOptions.CaCertsKeyStoreFileChooser.button"));
	if (iRtnValue == JFileChooser.APPROVE_OPTION)
	{
		m_jtfCaCertsFile.setText(chooser.getSelectedFile().toString());
		m_jtfCaCertsFile.setCaretPosition(0);
	}
}
 
Example 10
Source File: RootDirectoryAction.java    From DiskBrowser with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void actionPerformed (ActionEvent e)
// ---------------------------------------------------------------------------------//
{
  JFileChooser chooser = new JFileChooser (System.getProperty ("user.home"));
  chooser.setDialogTitle ("Select FOLDER containing disk images");
  chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
  if (rootFolder != null)
    chooser.setSelectedFile (rootFolder);

  int result = chooser.showDialog (null, "Accept");
  if (result == JFileChooser.APPROVE_OPTION)
  {
    File rootDirectoryFile = chooser.getSelectedFile ();
    if (!rootDirectoryFile.isDirectory ())
      rootDirectoryFile = rootDirectoryFile.getParentFile ();
    if (rootDirectoryFile != null)
      notifyListeners (rootDirectoryFile);
  }
}
 
Example 11
Source File: ForkOptions.java    From Logisim with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent event) {
	Object src = event.getSource();
	if (src == selectFolderButton) {
		JFileChooser chooser = JFileChoosers.create();
		chooser.setDialogTitle(Strings.get("selectDialogTitle"));
		chooser.setApproveButtonText(Strings.get("selectDialogButton"));
		chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
		int action = chooser.showOpenDialog(getPreferencesFrame());
		if (action == JFileChooser.APPROVE_OPTION) {
			File folder = chooser.getSelectedFile();
			AppPreferences.setLibrariesFolder(folder);
		}
	} else if (src == loadLibrariesFolderAtStartup) {
		boolean enabled = loadLibrariesFolderAtStartup.isSelected();
		libraryFolderField.setEnabled(enabled);
		selectFolderButton.setEnabled(enabled);
	}
}
 
Example 12
Source File: XCASFileOpenEventHandler.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Action performed.
 *
 * @param event the event
 * @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
 */
@Override
public void actionPerformed(ActionEvent event) {
  JFileChooser fileChooser = new JFileChooser();
  fileChooser.setDialogTitle("Open XCAS file");
  if (this.main.getXcasFileOpenDir() != null) {
    fileChooser.setCurrentDirectory(this.main.getXcasFileOpenDir());
  }
  int rc = fileChooser.showOpenDialog(this.main);
  if (rc == JFileChooser.APPROVE_OPTION) {
    File xcasFile = fileChooser.getSelectedFile();
    if (xcasFile.exists() && xcasFile.isFile()) {
      try {
        this.main.setXcasFileOpenDir(xcasFile.getParentFile());
        Timer time = new Timer();
        time.start();
        SAXParserFactory saxParserFactory = XMLUtils.createSAXParserFactory();
        SAXParser parser = saxParserFactory.newSAXParser();
        XCASDeserializer xcasDeserializer = new XCASDeserializer(this.main.getCas()
            .getTypeSystem());
        this.main.getCas().reset();
        parser.parse(xcasFile, xcasDeserializer.getXCASHandler(this.main.getCas()));
        time.stop();
        this.main.handleSofas();
        this.main.setTitle("XCAS");
        this.main.updateIndexTree(true);
        this.main.setRunOnCasEnabled();
        this.main.setEnableCasFileReadingAndWriting();
        this.main.setStatusbarMessage("Done loading XCAS file in " + time.getTimeSpan() + ".");
      } catch (Exception e) {
        e.printStackTrace();
        this.main.handleException(e);
      }
    }
  }
}
 
Example 13
Source File: ApplicationSnapshot.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public void saveAs() {
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle(NbBundle.getMessage(ApplicationSnapshot.class, "LBL_Save_Application_Snapshot_As")); // NOI18N
    chooser.setSelectedFile(new File(getFile().getName()));
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.setFileFilter(getCategory().getFileFilter());
    if (chooser.showSaveDialog(WindowManager.getDefault().getMainWindow()) == JFileChooser.APPROVE_OPTION) {
        String categorySuffix = ApplicationSnapshotCategory.SUFFIX;
        String filePath = chooser.getSelectedFile().getAbsolutePath();
        if (!filePath.endsWith(categorySuffix)) filePath += categorySuffix;
        final File file = new File(filePath);
        VisualVM.getInstance().runTask(new Runnable() {
            public void run() {
                ProgressHandle pHandle = null;
                try {
                    pHandle = ProgressHandleFactory.createHandle(NbBundle.getMessage(ApplicationSnapshot.class, "MSG_Saving", DataSourceDescriptorFactory.getDescriptor(ApplicationSnapshot.this).getName()));  // NOI18N
                    pHandle.setInitialDelay(0);
                    pHandle.start();
                    saveArchive(file);
                } finally {
                    final ProgressHandle pHandleF = pHandle;
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() { if (pHandleF != null) pHandleF.finish(); }
                    });
                }
            }
        });
    }
}
 
Example 14
Source File: ProxyFrame.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
private String selectExportDir() {
    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(new File(Configuration.lastExportDir.get()));
    chooser.setDialogTitle(translate("export.select.directory"));
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setAcceptAllFileFilterUsed(false);
    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        final String selFile = Helper.fixDialogFile(chooser.getSelectedFile()).getAbsolutePath();
        Configuration.lastExportDir.set(Helper.fixDialogFile(chooser.getSelectedFile()).getAbsolutePath());
        return selFile;
    }
    return null;
}
 
Example 15
Source File: FPMLParserTest.java    From finmath-lib with Apache License 2.0 5 votes vote down vote up
/**
 * This main method will prompt the user for a test file an run the test with the given file.
 *
 * @param args Arguments - not used.
 * @throws ParserConfigurationException Thrown by the parser.
 * @throws IOException Thrown, e.g., if the file could not be opened.
 * @throws SAXException Thrown by the XML parser.
 */
public static void main(final String[] args) throws SAXException, IOException, ParserConfigurationException
{
	final JFileChooser jfc = new JFileChooser(System.getProperty("user.home"));
	jfc.setDialogTitle("Choose XML");
	jfc.setFileFilter(new FileNameExtensionFilter("FIPXML (.xml)", "xml"));
	if(jfc.showOpenDialog(null) != JFileChooser.APPROVE_OPTION) {
		System.exit(1);
	}

	(new FPMLParserTest(jfc.getSelectedFile())).testGetSwapProductDescriptor();
}
 
Example 16
Source File: ProjectLibraryActions.java    From Logisim with GNU General Public License v3.0 5 votes vote down vote up
public static void LoadLogisimLibraryFromChooser(Project proj) {
	Loader loader = proj.getLogisimFile().getLoader();
	JFileChooser chooser = loader.createChooser();
	chooser.setDialogTitle(Strings.get("loadLogisimDialogTitle"));
	chooser.setFileFilter(Loader.LOGISIM_FILTER);
	int check = chooser.showOpenDialog(proj.getFrame());
	if (check == JFileChooser.APPROVE_OPTION)
		LoadLogisimLibrary(proj, chooser.getSelectedFile());
}
 
Example 17
Source File: MaskFormActions.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private void importMasks() {
    final JFileChooser fileChooser = new SnapFileChooser();
    fileChooser.setDialogTitle("Import Masks from file");
    final FileFilter bmdFilter = new SnapFileFilter("BITMASK_DEFINITION_FILE", ".bmd",
                                                    "Bitmask definition files (*.bmd)");
    fileChooser.addChoosableFileFilter(bmdFilter);
    final FileFilter bmdxFilter = new SnapFileFilter("BITMASK_DEFINITION_FILE_XML", ".bmdx",
                                                     "Bitmask definition xml files (*.bmdx)");
    fileChooser.addChoosableFileFilter(bmdxFilter);
    final FileFilter xmlFilter = new SnapFileFilter("XML", ".xml", "XML files (*.xml)");
    fileChooser.setFileFilter(xmlFilter);
    fileChooser.setCurrentDirectory(getDirectory());
    fileChooser.setMultiSelectionEnabled(true);
    if (fileChooser.showOpenDialog(SwingUtilities.getWindowAncestor(maskTopComponent)) == JFileChooser.APPROVE_OPTION) {
        final File file = fileChooser.getSelectedFile();
        if (file != null) {
            setDirectory(file.getAbsoluteFile().getParentFile());
            if (file.canRead()) {
                if (bmdFilter.accept(file)) {
                    importMaskFromBmd(file);
                } else if (bmdxFilter.accept(file)) {
                    importMasksFromBmdx(file);
                } else {
                    importMasksFromXml(file);
                }

            }
        }
    }
}
 
Example 18
Source File: InstallDocSourcePanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void btnFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFileActionPerformed
    JFileChooser chooser = new JFileChooser(lastFolder);
    chooser.setDialogTitle(isJavadoc() ? NbBundle.getMessage(InstallDocSourcePanel.class, "TIT_Select_javadoc_zip")
                                       : NbBundle.getMessage(InstallDocSourcePanel.class, "TIT_Select_source_zip"));
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setFileFilter(new FileFilter() {
        @Override
        public boolean accept(File f) {
            return (f.isDirectory() || f.getName().toLowerCase().endsWith(".jar") || f.getName().toLowerCase().endsWith(".zip")); //NOI18N
        }
        @Override
        public String getDescription() {
            
            return isJavadoc() ? NbBundle.getMessage(InstallDocSourcePanel.class, "LBL_Select_javadoc_zip")
                               : NbBundle.getMessage(InstallDocSourcePanel.class, "LBL_Select_source_zip");
        }
    });
    chooser.setMultiSelectionEnabled(false);
    if (txtFile.getText().trim().length() > 0) {
        File fil = new File(txtFile.getText().trim());
        if (fil.exists()) {
            chooser.setSelectedFile(fil);
        }
    }
    int ret = chooser.showDialog(SwingUtilities.getWindowAncestor(this), BTN_Select());
    if (ret == JFileChooser.APPROVE_OPTION) {
        txtFile.setText(chooser.getSelectedFile().getAbsolutePath());
        txtFile.requestFocusInWindow();
    }

}
 
Example 19
Source File: MainFrame.java    From beast-mcmc with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void doLoadSettings() {

        JFileChooser chooser = new JFileChooser();
        chooser.setDialogTitle("Load...");
        chooser.setMultiSelectionEnabled(false);
        chooser.setCurrentDirectory(workingDirectory);

        int returnVal = chooser.showOpenDialog(Utils.getActiveFrame());
        if (returnVal == JFileChooser.APPROVE_OPTION) {

            File file = chooser.getSelectedFile();

            loadSettings(file);

            File tmpDir = chooser.getCurrentDirectory();
            if (tmpDir != null) {
                workingDirectory = tmpDir;
            }

            setStatus("Loaded " + file.getAbsolutePath());

        }// END: approve check

    }
 
Example 20
Source File: OpenStegoUI.java    From openstego with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Method to get the display file chooser and return the selected file name
 *
 * @param dialogTitle Title for the file chooser dialog box
 * @param filterDesc Description to be displayed for the filter in file chooser
 * @param allowedExts Allowed file extensions for the filter
 * @param allowFileDir Type of objects allowed to be selected (FileBrowser.ALLOW_FILE,
 *        FileBrowser.ALLOW_DIRECTORY or FileBrowser.ALLOW_FILE_AND_DIR)
 * @param multiSelect Flag to indicate whether multiple file selection is allowed or not
 * @return Name of the selected file (null if no file was selected)
 */
public String getFileName(String dialogTitle, String filterDesc, List<String> allowedExts, int allowFileDir, boolean multiSelect) {
    int retVal = 0;
    String fileName = null;
    File[] files = null;

    JFileChooser chooser = new JFileChooser(lastFolder);
    chooser.setMultiSelectionEnabled(multiSelect);
    switch (allowFileDir) {
        case ALLOW_FILE:
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            break;
        case ALLOW_DIRECTORY:
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            break;
        case ALLOW_FILE_AND_DIR:
            chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            break;
    }

    if (filterDesc != null) {
        chooser.setFileFilter(new FileBrowserFilter(filterDesc, allowedExts));
    }
    chooser.setDialogTitle(dialogTitle);
    retVal = chooser.showOpenDialog(null);

    if (retVal == JFileChooser.APPROVE_OPTION) {
        if (multiSelect) {
            StringBuffer fileList = new StringBuffer();
            files = chooser.getSelectedFiles();
            for (int i = 0; i < files.length; i++) {
                if (i != 0) {
                    fileList.append(";");
                }
                fileList.append(files[i].getPath());
            }
            fileName = fileList.toString();
        } else {
            fileName = chooser.getSelectedFile().getPath();
        }
        lastFolder = chooser.getSelectedFile().getParent();
    }

    return fileName;
}