Here you can find the source of selectFile(final int openMode, final String title, final String buttonText, final String lastDirectoryUsed, final Component parent, final String suffix, final String description)
public static File selectFile(final int openMode, final String title, final String buttonText, final String lastDirectoryUsed, final Component parent, final String suffix, final String description)
//package com.java2s; import java.awt.Component; import java.io.File; import javax.swing.JFileChooser; public class Main { /**/*from w w w.j av a 2s. c o m*/ * Function to open a JFileChooser and set it properly. * * @return a File object if one has been chosen. Null otherwise. */ public static File selectFile(final int openMode, final String title, final String buttonText, final String lastDirectoryUsed, final Component parent, final String suffix, final String description) { JFileChooser chooser = new JFileChooser(lastDirectoryUsed); chooser.setFileHidingEnabled(false); chooser.setDialogTitle(title); chooser.setFileFilter(new javax.swing.filechooser.FileFilter() { @Override public boolean accept(File pathname) { if (pathname.isDirectory()) { return true; } return pathname.getName().endsWith(suffix); } @Override public String getDescription() { return description; } }); int returnVal = chooser.showDialog(parent, buttonText); if (returnVal != JFileChooser.APPROVE_OPTION) { return null; } return chooser.getSelectedFile(); } }