Java JFileChooser .setFileSelectionMode (int mode)

Syntax

JFileChooser.setFileSelectionMode(int mode) has the following syntax.

public void setFileSelectionMode(int mode)

Example

In the following code shows how to use JFileChooser.setFileSelectionMode(int mode) method.


import javax.swing.JFileChooser;
//from w  ww . ja  va 2s  .  c o m
public class Main {

  public static void main(String[] a) {

    JFileChooser fileChooser = new JFileChooser();

    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    fileChooser.showOpenDialog(null);
  }

}