Here you can find the source of fileOpen(Frame parent, String typename, String ext)
public static File fileOpen(Frame parent, String typename, String ext)
//package com.java2s; //License from project: Open Source License import java.awt.Frame; import java.io.File; import javax.swing.JFileChooser; import javax.swing.filechooser.FileNameExtensionFilter; public class Main { static String lastpathload = null; public static File fileOpen(Frame parent, String typename, String ext) { JFileChooser chooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter(typename, ext); chooser.setFileFilter(filter);// www . j av a2 s . com chooser.setCurrentDirectory(lastpathload != null ? new File(lastpathload) : null); int returnVal = chooser.showOpenDialog(parent); if (returnVal == JFileChooser.APPROVE_OPTION) { lastpathload = chooser.getSelectedFile().getPath(); return chooser.getSelectedFile(); } return null; } }