JFileChooser.DIRECTORIES_ONLY has the following syntax.
public static final int DIRECTORIES_ONLY
In the following code shows how to use JFileChooser.DIRECTORIES_ONLY field.
import javax.swing.JFileChooser; public class Main { public static void main(String[] argv) { JFileChooser fileChooser = new JFileChooser("."); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); } }