Here you can find the source of getFile()
public static File getFile()
//package com.java2s; //License from project: Open Source License import java.io.File; import javax.swing.JFileChooser; public class Main { public static File getFile() { // create a file chooser JFileChooser fileChooser = new JFileChooser(); // show open file dialog int result = fileChooser.showOpenDialog(null); if (result == JFileChooser.APPROVE_OPTION) { return fileChooser.getSelectedFile(); }/*from ww w . j a va 2 s .co m*/ return null; } }