Here you can find the source of chooseFile(String title)
public static File chooseFile(String title) throws FileNotFoundException
//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; } }