Java JFileChooser run_file_chooser(String file_desc, String extension)

Here you can find the source of run_file_chooser(String file_desc, String extension)

Description

rufilchooser

License

Open Source License

Declaration

public static File run_file_chooser(String file_desc, String extension) 

Method Source Code

//package com.java2s;
/* /* ww  w  . j a  va 2  s . c  o m*/
 * Copyright (C) 2015 Wen, Chifeng <https://sourceforge.net/u/daviesx/profile/>
 *
 * This program 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 2
 * of the License, or (at your option) any later version.
 *
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

import java.io.File;

import javax.swing.JFileChooser;

import javax.swing.filechooser.FileNameExtensionFilter;

public class Main {
    public static File run_file_chooser(String file_desc, String extension) {
        JFileChooser chooser = new JFileChooser();
        FileNameExtensionFilter filter = new FileNameExtensionFilter(file_desc, extension);
        chooser.setFileFilter(filter);
        int ret_val = chooser.showOpenDialog(null);
        if (ret_val == JFileChooser.APPROVE_OPTION) {
            return chooser.getSelectedFile();
        } else {
            return null;
        }
    }
}

Related

  1. readAsString(File file)
  2. readAsString(File file)
  3. readFromFile()
  4. removeChoosableFileFilters(JFileChooser fc)
  5. retrieveFilesFromDir(File basedir, FileFilter filter)
  6. save(JFileChooser fileChooser, Runnable action)
  7. saveFile(Component parent, File defaultFile)
  8. saveFile(String title, File currentDir, javax.swing.filechooser.FileFilter filter)
  9. saveObject(final Object content, final String description, final String extension, final File file)