Here you can find the source of chooseFile(Component parentComponent, String title, File curDir, String suffix)
public static File chooseFile(Component parentComponent, String title, File curDir, String suffix)
//package com.java2s; //License from project: Apache License import java.awt.Component; import java.io.File; import javax.swing.JFileChooser; import javax.swing.filechooser.FileNameExtensionFilter; public class Main { public static File chooseFile(Component parentComponent, String title) { JFileChooser jfc = new JFileChooser(); jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); jfc.showDialog(parentComponent, title); return jfc.getSelectedFile(); }/*from www. j av a 2 s .co m*/ public static File chooseFile(Component parentComponent, String title, String suffix) { JFileChooser jfc = new JFileChooser(); jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); jfc.setFileFilter(new FileNameExtensionFilter("." + suffix, suffix)); jfc.showDialog(parentComponent, title); return jfc.getSelectedFile(); } public static File chooseFile(Component parentComponent, String title, File curDir, String suffix) { JFileChooser jfc = new JFileChooser(); jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); jfc.setFileFilter(new FileNameExtensionFilter("." + suffix, suffix)); if (curDir != null) { jfc.setCurrentDirectory(curDir); } jfc.showDialog(parentComponent, title); return jfc.getSelectedFile(); } }