Java tutorial
import java.io.File; import javax.swing.JFileChooser; public class Main { public static void main(String[] argv) { JFileChooser fileChooser = new JFileChooser(new File(".")); fileChooser.addChoosableFileFilter(new MyFilter()); fileChooser.showOpenDialog(null); System.out.println(fileChooser.getSelectedFile()); } } class MyFilter extends javax.swing.filechooser.FileFilter { public boolean accept(File file) { String filename = file.getName(); return filename.endsWith(".java"); } public String getDescription() { return "*.java"; } }