Java tutorial
//package com.java2s; import java.awt.Component; import java.io.File; import javax.swing.JFileChooser; public class Main { public static File chooseDirectory(Component parentComponent, String title) { JFileChooser jfc = new JFileChooser(); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); jfc.showDialog(parentComponent, title); return jfc.getSelectedFile(); } }