JDirectoryChooser provides a GUI for navigating the file system, and then either choosing an existing directory from a tree or managing file system directories' tree structure by creating new directories, renaming, copying, moving or deleting existing directories.
To display a directory chooser, you can either add an instance of JDirectoryChooser to a container, or use the JDirectoryChooser API to show a modal dialog that contains a directory chooser.
A JDirectoryChooser object only presents the GUI for choosing and managing directories. Your program is responsible for doing something with the chosen directory, such as using it as default location for output or doing something with the content of the chosen directory... etc.
The typical usage of the directory chooser dialog is shown below:
/** * Event handler. * * @param e the action event. */ public void actionPerformed(ActionEvent e) { File dir = JDirectoryChooser.showDialog(aParent)); if (dir != null) { // Real application would handle user's selection here. System.out.println("You selected: " + dir.getName()); } else { System.out.println("Operation canceled by user"); } }