Here you can find the source of getFileName(Component parent)
public static String getFileName(Component parent)
//package com.java2s; //License from project: Open Source License import java.awt.*; import javax.swing.*; public class Main { private static JFileChooser mFileChoose = null; /**/*ww w .jav a 2s .c o m*/ * get file name */ public static String getFileName(Component parent) { if (mFileChoose == null) { mFileChoose = new JFileChooser(); mFileChoose.setFileSelectionMode(JFileChooser.FILES_ONLY); } int returnVal = mFileChoose.showOpenDialog(parent); if (returnVal == JFileChooser.APPROVE_OPTION) { return mFileChoose.getSelectedFile().getAbsolutePath(); } else { return null; } } }