Java JFileChooser getFileChooser()

Here you can find the source of getFileChooser()

Description

Returns a JFileChooser with the filter 'All Files'

License

Open Source License

Return

JFileChooser

Declaration

private static JFileChooser getFileChooser() 

Method Source Code

//package com.java2s;
/*/*from ww w .  jav a  2s  .co  m*/
 * Copyright 2010 Ivan Bogicevic, Markus Knau?, Daniel Kulesz, Holger R?der, Matthias Wetzel
 * 
 * This file is part of Jabi.
 * 
 * Jabi is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Jabi is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Jabi.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.io.File;
import javax.swing.JFileChooser;

import javax.swing.filechooser.FileFilter;

public class Main {
    private static JFileChooser fileChooser = null;

    /**
     * Returns a JFileChooser with the filter 'All Files'
     * @return JFileChooser 
     */
    private static JFileChooser getFileChooser() {
        if (fileChooser == null) {
            fileChooser = new JFileChooser();
            fileChooser.setFileFilter(new FileFilter() {
                @Override
                public String getDescription() {
                    return "Alle Dateien";
                }

                @Override
                public boolean accept(File f) {
                    return true;
                }
            });
        }
        return fileChooser;
    }
}

Related

  1. getFile(String title, File initialDir)
  2. getFileChooser()
  3. getFileChooser()
  4. getFileChooser()
  5. getFileChooser()
  6. getFileChooser()
  7. getFileChooser()
  8. getFileChooser(Component parent, JFileChooser fileChooser, JComponent accessory)
  9. getFileChooserSelectedFile(JFileChooser fchooser, boolean directoryOnly, String fileName)