Here you can find the source of openFile(String fileExtension)
public static String openFile(String fileExtension)
//package com.java2s; //License from project: Open Source License import java.io.*; import javax.swing.JFileChooser; public class Main { public static String openFile(String fileExtension) { JFileChooser dlgFile = new JFileChooser(); dlgFile.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); dlgFile.setApproveButtonText("Open"); int returnVal = dlgFile.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = dlgFile.getSelectedFile(); return file.getAbsolutePath(); }//from ww w. j ava2s .c o m return ""; } }