Java JFileChooser chooseFile(String title)

Here you can find the source of chooseFile(String title)

Description

choose File

License

Open Source License

Declaration

public static File chooseFile(String title) throws FileNotFoundException 

Method Source Code


//package com.java2s;
import java.io.File;
import java.io.FileNotFoundException;
import javax.swing.JFileChooser;

public class Main {
    public static File chooseFile(String title) throws FileNotFoundException {
        File f = null;//from w ww.  j  a  va  2  s. c o m
        JFileChooser chooser = new JFileChooser();
        chooser.setDialogTitle(title);
        chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        chooser.setCurrentDirectory(new File("."));

        int returnVal = chooser.showOpenDialog(null);
        if (returnVal == JFileChooser.APPROVE_OPTION)
            return f = chooser.getSelectedFile();
        else
            return f;
    }
}

Related

  1. chooseFile(Component parentComponent, String title, File curDir, String suffix)
  2. chooseFile(File initialFile, boolean load)
  3. chooseFile(final Component parent, final boolean filesOnly, final String title, final File selectedFile, final FileFilter filter)
  4. ChooseFile(final String desc, final String[] allowed_extensions, String suggested_dir)
  5. chooseFile(JFileChooser fc, Component parent)
  6. chooseFiles()
  7. chooseFiles(final Component parent)
  8. chooseFiles(String title, File currentDir)
  9. chooseFilesForOpen(String title, FileFilter filter, File initialDir)