Java JFileChooser getChoiceFileFromUser()

Here you can find the source of getChoiceFileFromUser()

Description

get Choice File From User

License

Open Source License

Declaration

public static File getChoiceFileFromUser() 

Method Source Code


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

import java.io.File;

import javax.swing.JFileChooser;

public class Main {
    private static final JFileChooser fc = new JFileChooser();

    public static File getChoiceFileFromUser() {

        fc.setMultiSelectionEnabled(false);
        fc.setFileSelectionMode(JFileChooser.FILES_ONLY);

        int exitStatus = fc.showOpenDialog(null);

        if (exitStatus == JFileChooser.APPROVE_OPTION) {

            return fc.getSelectedFile();

        } else {/*  ww  w.  j a  v a  2 s  .c o  m*/

            return null;

        }

    }
}

Related

  1. createReportFileChooser(String curDir, File defaultReportFile)
  2. createUserDefinedProfileFileChooser()
  3. directoryFetch(File starting)
  4. exportFile(JFileChooser fileChooser, String contents)
  5. fileChooser()
  6. getDir(String title, String initDir, boolean allowFiles, Component parent)
  7. getDriveDisplayName(File path)
  8. getExtension(File f)
  9. getFile()