javax.swing.JFileChooser#setDialogTitle ( )源码实例Demo

下面列出了javax.swing.JFileChooser#setDialogTitle ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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();
    }

}
 
源代码2 项目: Logisim   文件: ForkOptions.java
@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);
	}
}
 
源代码3 项目: DiskBrowser   文件: RootDirectoryAction.java
@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);
  }
}
 
源代码4 项目: portecle   文件: DOptions.java
/**
 * 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);
	}
}
 
源代码5 项目: smsbackupreader   文件: GUI.java
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!");
	}
}
 
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();
    }

}
 
源代码7 项目: netbeans   文件: ProjectAttributesPanelVisual.java
@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());
        }

    }
}
 
源代码8 项目: mars-sim   文件: InteractiveTerm.java
/**
 * 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;
}
 
源代码9 项目: CodenameOne   文件: FilePropertyEditor.java
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);
  }
}
 
源代码10 项目: netbeans   文件: PanelProjectLocationVisual.java
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() );
            }   
}
 
源代码11 项目: netbeans   文件: PanelProjectLocationVisual.java
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();
    }
}
 
源代码12 项目: netbeans   文件: InstallDocSourcePanel.java
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();
    }

}
 
源代码13 项目: jpexs-decompiler   文件: ProxyFrame.java
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;
}
 
源代码14 项目: visualvm   文件: ApplicationSnapshot.java
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(); }
                    });
                }
            }
        });
    }
}
 
源代码15 项目: uima-uimaj   文件: XCASFileOpenEventHandler.java
/**
 * 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);
      }
    }
  }
}
 
源代码16 项目: finmath-lib   文件: FPMLParserTest.java
/**
 * 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();
}
 
源代码17 项目: Logisim   文件: ProjectLibraryActions.java
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());
}
 
源代码18 项目: snap-desktop   文件: MaskFormActions.java
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);
                }

            }
        }
    }
}
 
源代码19 项目: openstego   文件: OpenStegoUI.java
/**
 * 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;
}
 
源代码20 项目: beast-mcmc   文件: MainFrame.java
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

    }