Java JFileChooser getNewFileChooser()

Here you can find the source of getNewFileChooser()

Description

get New File Chooser

License

Open Source License

Declaration

public static JFileChooser getNewFileChooser() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;

public class Main {
    public static final FileNameExtensionFilter FILE_FILTER_EXCEL = new FileNameExtensionFilter(
            "Planilhas do Excel (*.xls; *.xlsx)", "xls", "xlsx");
    public static final FileNameExtensionFilter FILE_FILTER_CSV = new FileNameExtensionFilter(
            "Arquivos CSV (*.csv; *.txt)", "csv", "txt");

    public static JFileChooser getNewFileChooser() {
        return getNewFileChooser(FILE_FILTER_EXCEL, FILE_FILTER_CSV);
    }//from   w w w. j a v  a 2s . co  m

    public static JFileChooser getNewFileChooser(FileNameExtensionFilter... extensionFilters) {

        JFileChooser fileChooser = new JFileChooser(System.getProperty("user.dir"));
        fileChooser.setAcceptAllFileFilterUsed(false);

        for (FileNameExtensionFilter extensionFilter : extensionFilters) {
            fileChooser.addChoosableFileFilter(extensionFilter);
        }

        return fileChooser;

    }
}

Related

  1. getFixedFileChooser(File file)
  2. getIcon(File file)
  3. getJFileChooser(String title, File initialDirectory, File initialFile, final FilenameFilter filter, int directoryMode)
  4. getLoadFilename(Component parent)
  5. getLoadFiles(String message, File openDefaultDirectory, String description, String... extensions)
  6. getOpenFile(String defaultPath)
  7. getOpenFile(String name, String currentDirectory)
  8. getOpenFile(String title)
  9. getPropertiesFile(boolean saving, String startName, String extension, String description)