Java JFileChooser getFixedFileChooser(File file)

Here you can find the source of getFixedFileChooser(File file)

Description

Returns a file chooser that should not trip the bug with Java and Windows XP zip/rar folder feature.

License

Open Source License

Return

a safe file chooser

Declaration

public static JFileChooser getFixedFileChooser(File file) 

Method Source Code

//package com.java2s;
//License from project: GNU General Public License 

import java.io.File;

import javax.swing.JFileChooser;

public class Main {
    /**//from w w w.  ja v a2s .c  o  m
     * <strong>You must always use this!</strong> This is a convenience method,
     * see the actual for details.
     * 
     * @see #getFixedFileChooser(File)
     */
    public static JFileChooser getFixedFileChooser() {
        return getFixedFileChooser(null);
    }

    /**
     * <p>
     * Returns a file chooser that should not trip the bug with Java and Windows
     * XP zip/rar folder feature. Also checks and reports with a modal dialog if
     * there are zips on desktop, as the does not seem to work in all
     * environments. For more information about the bug see e.g. #5050516 at
     * bugs.sun.com.
     * </p>
     * 
     * <p>
     * <strong>You must always use this!</strong>
     * </p>
     * 
     * @return a safe file chooser
     */
    public static JFileChooser getFixedFileChooser(File file) {

        JFileChooser fileChooser = file != null ? new JFileChooser(file) : new JFileChooser();
        fileChooser.putClientProperty("FileChooser.useShellFolder", Boolean.FALSE);

        return fileChooser;
    }
}

Related

  1. getFilePath(Component parent, JFileChooser fileChooser, String title, FileFilter filter)
  2. getFiles(String title, String initialRoot, String initialFile)
  3. getFilesToOpen(File startDirectory, Component parent, String... filters)
  4. getFileToSave(String description, String extension, Component component)
  5. getFileWithExtension(JFileChooser c)
  6. getIcon(File file)
  7. getJFileChooser(String title, File initialDirectory, File initialFile, final FilenameFilter filter, int directoryMode)
  8. getLoadFilename(Component parent)
  9. getLoadFiles(String message, File openDefaultDirectory, String description, String... extensions)