JFileChooser.showOpenDialog(Component parent) has the following syntax.
public int showOpenDialog(Component parent) throws HeadlessException
In the following code shows how to use JFileChooser.showOpenDialog(Component parent) method.
import javax.swing.JFileChooser; /*from ww w. j a v a2s. c o m*/ public class Main { public static void main(String[] a) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.showOpenDialog(null); } }