Java Swing Tutorial - 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;
//  www  .  j  ava  2  s  .co m
public class Main {

  public static void main(String[] a) {

    JFileChooser fileChooser = new JFileChooser();

    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    fileChooser.showOpenDialog(null);
  }

}