Java JFileChooser chooseFile(JFileChooser fc, Component parent)

Here you can find the source of chooseFile(JFileChooser fc, Component parent)

Description

choose File

License

Open Source License

Declaration

public static File chooseFile(JFileChooser fc, Component parent) 

Method Source Code


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

public class Main {
    public static File chooseFile(JFileChooser fc, Component parent) {

        int returnVal = fc.showOpenDialog(parent);

        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            return file;
        } else/*from   ww w.j av a  2  s . c om*/
            return null;
    }
}

Related

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