Here you can find the source of getChoiceFileFromUser()
public static File getChoiceFileFromUser()
//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; } } }