Java tutorial
//package com.java2s; import java.io.File; import javax.swing.JFileChooser; import javax.swing.JPanel; public class Main { public static File promptForImageFile(JPanel parent) { JFileChooser chooser = new JFileChooser(); int returnVal = chooser.showOpenDialog(parent); if (returnVal == JFileChooser.APPROVE_OPTION) { System.out.println("You chose to open this file: " + chooser.getSelectedFile().getName()); return chooser.getSelectedFile(); } return null; } }