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

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

源代码1 项目: netbeans   文件: SettingsPanel.java
private void btnDirectoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDirectoryActionPerformed
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle("Select alternate directory");
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setFileHidingEnabled(false);
    String path = txtDirectory.getText();
    if (path == null || path.trim().length() == 0) {
        path = new File(System.getProperty("user.home")).getAbsolutePath(); //NOI18N
    }
    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();
        txtDirectory.setText(projectDir.getAbsolutePath());
    }

}
 
源代码2 项目: netbeans   文件: SettingsPanel.java
@Messages("TIT_GradleUserHome=Select Gradle User Home")
private void btGradleUserHomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btGradleUserHomeActionPerformed
    final GradleSettings settings = GradleSettings.getDefault();
    settings.getGradleUserHome();

    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle(Bundle.TIT_GradleUserHome());
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setFileHidingEnabled(false);
    String path = tfGradleUserHome.getText();

    if (path.length() > 0) {
        File f = new File(path);
        if (f.exists()) {
            chooser.setSelectedFile(f);
        }
    }
    if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
        File home = chooser.getSelectedFile();
        tfGradleUserHome.setText(home.getAbsolutePath());
        gdm = GradleDistributionManager.get(home);
        cbGradleVersion.repaint();
    }
}
 
源代码3 项目: netbeans   文件: RemoteRepository.java
private void onBrowse() {
    String path = settingsPanel.txtIdentityFile.getText();
    if (path.isEmpty()) {
        path = getDefaultIdentityFilePath();
    }
    File file = new File(path);
    JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle.getMessage(RemoteRepositoryPanel.class, "RepositoryPanel.IdentityFile.FileChooser.Descritpion"), //NOI18N
            path.isEmpty() ? null : file.getParentFile());
    if (!path.isEmpty()) {
        fileChooser.setSelectedFile(file);
    }
    fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
    fileChooser.setDialogTitle(NbBundle.getMessage(RemoteRepositoryPanel.class, "RepositoryPanel.IdentityFile.FileChooser.Title")); //NOI18N
    fileChooser.setMultiSelectionEnabled(false);
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileChooser.setFileHidingEnabled(false);
    if (JFileChooser.APPROVE_OPTION == fileChooser.showDialog(panel, null)) {
        File f = fileChooser.getSelectedFile();
        settingsPanel.txtIdentityFile.setText(f.getAbsolutePath());
    }
}
 
源代码4 项目: netbeans   文件: SSHKeysPanel.java
private File openFile() {
    String home = System.getProperty("user.home"); // NOI18N
    JFileChooser chooser = new JFileChooser(home);
    chooser.setMultiSelectionEnabled(false);
    chooser.setFileHidingEnabled(false);
    int dlgResult = chooser.showOpenDialog(this);
    if (JFileChooser.APPROVE_OPTION == dlgResult) {
        File result = chooser.getSelectedFile();
        if (result != null && !result.exists()) {
            result = null;
        }
        return result;
    } else {
        return null;
    }
}
 
源代码5 项目: freecol   文件: SaveDialog.java
/**
 * Creates a dialog to choose a file to load.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 * @param frame The owner frame.
 * @param directory The directory to display when choosing the file.
 * @param fileFilters The available file filters in the dialog.
 * @param defaultName Name of the default save game file.
 */
public SaveDialog(FreeColClient freeColClient, JFrame frame,
        File directory, FileFilter[] fileFilters, String defaultName) {
    super(freeColClient, frame);

    final JFileChooser fileChooser = new JFileChooser(directory);
    if (fileFilters.length > 0) {
        for (FileFilter fileFilter : fileFilters) {
            fileChooser.addChoosableFileFilter(fileFilter);
        }
        fileChooser.setFileFilter(fileFilters[0]);
        fileChooser.setAcceptAllFileFilterUsed(false);
    }
    fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileChooser.setFileHidingEnabled(false);
    fileChooser.setSelectedFile(new File(defaultName));
    fileChooser.addActionListener((ActionEvent ae) ->
            setValue((JFileChooser.APPROVE_SELECTION
                    .equals(ae.getActionCommand()))
                ? fileChooser.getSelectedFile() : cancelFile));
    
    List<ChoiceItem<File>> c = choices();
    initializeDialog(frame, DialogType.QUESTION, true, fileChooser, null, c);
}
 
源代码6 项目: lucene-solr   文件: OpenIndexDialogFactory.java
@SuppressForbidden(reason = "FileChooser#getSelectedFile() returns java.io.File")
void browseDirectory(ActionEvent e) {
  File currentDir = getLastOpenedDirectory();
  JFileChooser fc = currentDir == null ? new JFileChooser() : new JFileChooser(currentDir);
  fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  fc.setFileHidingEnabled(false);
  int retVal = fc.showOpenDialog(dialog);
  if (retVal == JFileChooser.APPROVE_OPTION) {
    File dir = fc.getSelectedFile();
    idxPathCombo.insertItemAt(dir.getAbsolutePath(), 0);
    idxPathCombo.setSelectedIndex(0);
  }
}
 
源代码7 项目: amidst   文件: MainWindowDialogs.java
@CalledOnlyBy(AmidstThread.EDT)
private JFileChooser createSaveGameFileChooser() {
	JFileChooser result = new JFileChooser(runningLauncherProfile.getLauncherProfile().getSaves().toFile());
	result.setFileFilter(new LevelFileFilter());
	result.setAcceptAllFileFilterUsed(false);
	result.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
	result.setFileHidingEnabled(false);
	return result;
}
 
源代码8 项目: netbeans   文件: MavenGroupPanel.java
private void browseAddNewRuntime() {
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle(org.openide.util.NbBundle.getMessage(SettingsPanel.class, "TIT_Select2"));
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setFileHidingEnabled(false);
    int selected = comMavenHome.getSelectedIndex();
    String path = getSelectedRuntime(selected);
    if (path == null || path.trim().length() == 0) {
        path = new File(System.getProperty("user.home")).getAbsolutePath(); //NOI18N
    }
    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();
        String newRuntimePath = FileUtil.normalizeFile(projectDir).getAbsolutePath();
        boolean existed = false;
        List<String> runtimes = new ArrayList<String>();
        runtimes.addAll(predefinedRuntimes);
        runtimes.addAll(userDefinedMavenRuntimes);
        for (String runtime : runtimes) {
            if (runtime.equals(newRuntimePath)) {
                existed = true;
            }
        }
        if (!existed) {
            // do not add duplicated directory
            if (userDefinedMavenRuntimes.isEmpty()) {
                mavenHomeDataModel.insertElementAt(SEPARATOR, predefinedRuntimes.size());
            }
            userDefinedMavenRuntimes.add(newRuntimePath);
            mavenHomeDataModel.insertElementAt(newRuntimePath, runtimes.size() + 1);
        }
        comMavenHome.setSelectedItem(newRuntimePath);
    }
}
 
源代码9 项目: bytecode-viewer   文件: MainViewerGUI.java
public void rtC()
{
    JFileChooser fc = new JFileChooser();
    fc.setFileFilter(new FileFilter()
    {
        @Override
        public boolean accept(File f)
        {
            return true;
        }

        @Override
        public String getDescription()
        {
            return "JRE RT Library";
        }
    });
    fc.setFileHidingEnabled(false);
    fc.setAcceptAllFileFilterUsed(false);
    int returnVal = fc.showOpenDialog(BytecodeViewer.viewer);

    if (returnVal == JFileChooser.APPROVE_OPTION)
        try
        {
            BytecodeViewer.rt = fc.getSelectedFile().getAbsolutePath();
        }
        catch (Exception e1)
        {
            new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1);
        }
}
 
源代码10 项目: bytecode-viewer   文件: MainViewerGUI.java
public void pythonC()
{
    JFileChooser fc = new JFileChooser();
    fc.setFileFilter(new FileFilter()
    {
        @Override
        public boolean accept(File f)
        {
            return true;
        }

        @Override
        public String getDescription()
        {
            return "Python (Or PyPy for speed) 2.7 Executable";
        }
    });
    fc.setFileHidingEnabled(false);
    fc.setAcceptAllFileFilterUsed(false);
    int returnVal = fc.showOpenDialog(BytecodeViewer.viewer);

    if (returnVal == JFileChooser.APPROVE_OPTION)
        try
        {
            BytecodeViewer.python = fc.getSelectedFile().getAbsolutePath();
        }
        catch (Exception e1)
        {
            new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1);
        }
}
 
源代码11 项目: bytecode-viewer   文件: MainViewerGUI.java
public void library()
{
    JFileChooser fc = new JFileChooser();
    fc.setFileFilter(new FileFilter()
    {
        @Override
        public boolean accept(File f)
        {
            return f.isDirectory();
        }

        @Override
        public String getDescription()
        {
            return "Optional Library Folder";
        }
    });
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    fc.setFileHidingEnabled(false);
    fc.setAcceptAllFileFilterUsed(false);
    int returnVal = fc.showOpenDialog(BytecodeViewer.viewer);

    if (returnVal == JFileChooser.APPROVE_OPTION)
        try
        {
            BytecodeViewer.library = fc.getSelectedFile().getAbsolutePath();
        }
        catch (Exception e1)
        {
            new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1);
        }
}
 
源代码12 项目: bytecode-viewer   文件: MainViewerGUI.java
public void java()
{
    JFileChooser fc = new JFileChooser();
    fc.setFileFilter(new FileFilter()
    {
        @Override
        public boolean accept(File f)
        {
            return true;
        }

        @Override
        public String getDescription()
        {
            return "Java Executable (Inside Of JRE/JDK 'C:/programfiles/Java/JDK_xx/bin/java.exe')";
        }
    });
    fc.setFileHidingEnabled(false);
    fc.setAcceptAllFileFilterUsed(false);
    int returnVal = fc.showOpenDialog(BytecodeViewer.viewer);

    if (returnVal == JFileChooser.APPROVE_OPTION)
        try
        {
            BytecodeViewer.java = fc.getSelectedFile().getAbsolutePath();
        }
        catch (Exception e1)
        {
            new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1);
        }
}
 
源代码13 项目: netbeans   文件: ConfigurationPanel.java
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
    JFileChooser chooser = new JFileChooser();
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setFileHidingEnabled(false);
    String text = UiUtils.getValue(certTextField);
    if (text != null) {
        chooser.setSelectedFile(new File(text));
    }
    if (chooser.showOpenDialog(SwingUtilities.getWindowAncestor(this)) == JFileChooser.APPROVE_OPTION) {
        certTextField.setText(chooser.getSelectedFile().getAbsolutePath());
    }
}
 
源代码14 项目: netbeans   文件: ConfigurationLinuxPanel.java
private void certBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_certBrowseButtonActionPerformed
    JFileChooser chooser = new JFileChooser();
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setFileHidingEnabled(false);
    String text = UiUtils.getValue(certTextField);
    if (text != null) {
        chooser.setSelectedFile(new File(text));
    }
    if (chooser.showOpenDialog(SwingUtilities.getWindowAncestor(this)) == JFileChooser.APPROVE_OPTION) {
        certTextField.setText(chooser.getSelectedFile().getAbsolutePath());
    }
}
 
源代码15 项目: amidst   文件: MainWindowDialogs.java
@CalledOnlyBy(AmidstThread.EDT)
private JFileChooser createSaveGameFileChooser() {
	JFileChooser result = new JFileChooser(runningLauncherProfile.getLauncherProfile().getSaves().toFile());
	result.setFileFilter(new LevelFileFilter());
	result.setAcceptAllFileFilterUsed(false);
	result.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
	result.setFileHidingEnabled(false);
	return result;
}
 
源代码16 项目: netbeans   文件: VariablePanel.java
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
    JFileChooser chooser = new JFileChooser();
    chooser.setFileHidingEnabled(false);
    FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
    chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
    chooser.setMultiSelectionEnabled(false);
    chooser.setDialogTitle(NbBundle.getBundle(VariablePanel.class).getString("MSG_Choose_Folder"));
    if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
        File file = FileUtil.normalizeFile(chooser.getSelectedFile());
        locationTextField.setText(file.getAbsolutePath());
    }
}
 
源代码17 项目: bytecode-viewer   文件: MainViewerGUI.java
public void pythonC3()
{
    JFileChooser fc = new JFileChooser();
    fc.setFileFilter(new FileFilter()
    {
        @Override
        public boolean accept(File f)
        {
            return true;
        }

        @Override
        public String getDescription()
        {
            return "Python (Or PyPy for speed) 3.x Executable";
        }
    });
    fc.setFileHidingEnabled(false);
    fc.setAcceptAllFileFilterUsed(false);
    int returnVal = fc.showOpenDialog(BytecodeViewer.viewer);

    if (returnVal == JFileChooser.APPROVE_OPTION)
        try
        {
            BytecodeViewer.python3 = fc.getSelectedFile().getAbsolutePath();
        }
        catch (Exception e1)
        {
            new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1);
        }
}
 
源代码18 项目: hortonmachine   文件: GuiUtilities.java
public static File showSaveFileDialog( final Component parent, final String title, final File initialPath ) {
    RunnableWithParameters runnable = new RunnableWithParameters(){
        public void run() {
            JFileChooser fc = new JFileChooser();
            fc.setDialogTitle(title);
            fc.setDialogType(JFileChooser.SAVE_DIALOG);
            fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
            fc.setCurrentDirectory(initialPath);
            fc.setFileHidingEnabled(false);
            int r = fc.showOpenDialog(parent);
            if (r != JFileChooser.APPROVE_OPTION) {
                this.returnValue = null;
                return;
            }

            File selectedFile = fc.getSelectedFile();
            if (selectedFile != null && selectedFile.getParentFile().exists())
                PreferencesHandler.setLastPath(selectedFile.getParentFile().getAbsolutePath());
            this.returnValue = selectedFile;

        }
    };
    if (SwingUtilities.isEventDispatchThread()) {
        runnable.run();
    } else {
        try {
            SwingUtilities.invokeAndWait(runnable);
        } catch (Exception e) {
            Logger.INSTANCE.insertError("", "Can't show chooser dialog '" + title + "'.", e);
        }
    }
    return (File) runnable.getReturnValue();
}
 
源代码19 项目: lucene-solr   文件: CreateIndexDialogFactory.java
@SuppressForbidden(reason = "JFilechooser#getSelectedFile() returns java.io.File")
private void browseDirectory(JTextField tf) {
  JFileChooser fc = new JFileChooser(new File(tf.getText()));
  fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  fc.setFileHidingEnabled(false);
  int retVal = fc.showOpenDialog(dialog);
  if (retVal == JFileChooser.APPROVE_OPTION) {
    File dir = fc.getSelectedFile();
    tf.setText(dir.getAbsolutePath());
  }
}
 
源代码20 项目: hortonmachine   文件: GuiUtilities.java
public static File[] showOpenFilesDialog( final Component parent, final String title, final boolean multiselection,
        final File initialPath, final FileFilter filter ) {
    RunnableWithParameters runnable = new RunnableWithParameters(){
        public void run() {
            JFileChooser fc = new JFileChooser();
            fc.setDialogTitle(title);
            fc.setDialogType(JFileChooser.OPEN_DIALOG);
            fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
            fc.setMultiSelectionEnabled(multiselection);
            fc.setCurrentDirectory(initialPath);
            if (filter != null)
                fc.setFileFilter(filter);
            fc.setFileHidingEnabled(false);
            int r = fc.showOpenDialog(parent);
            if (r != JFileChooser.APPROVE_OPTION) {
                this.returnValue = null;
                return;
            }

            if (fc.isMultiSelectionEnabled()) {
                File[] selectedFiles = fc.getSelectedFiles();
                this.returnValue = selectedFiles;
            } else {
                File selectedFile = fc.getSelectedFile();
                if (selectedFile != null && selectedFile.exists())
                    PreferencesHandler.setLastPath(selectedFile.getAbsolutePath());
                this.returnValue = new File[]{selectedFile};
            }

        }
    };
    if (SwingUtilities.isEventDispatchThread()) {
        runnable.run();
    } else {
        try {
            SwingUtilities.invokeAndWait(runnable);
        } catch (Exception e) {
            Logger.INSTANCE.insertError("", "Can't show chooser dialog '" + title + "'.", e);
        }
    }
    return (File[]) runnable.getReturnValue();
}