Here you can find the source of openFile()
public static String openFile()
//package com.java2s; //License from project: Open Source License import java.io.File; import javax.swing.JFileChooser; public class Main { public static String openFile() { JFileChooser fc = null;/*from w w w. j a va 2s . c o m*/ fc = new JFileChooser(System.getProperty("user.home")); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = fc.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); if (file.getPath().equals("")) return null; return file.getAbsolutePath(); } return null; } }