Finally, the example program has commented-out lines of code that let you change the file selection mode. For example, the following line of code makes the file chooser able to select only directories, and not files: fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);