Java Swing Tutorial - Java JFileChooser ERROR_OPTION








Syntax

JFileChooser.ERROR_OPTION has the following syntax.

public static final int ERROR_OPTION

Example

In the following code shows how to use JFileChooser.ERROR_OPTION field.

//  w  ww  .j a v a2 s .co m
import javax.swing.JFileChooser;

public class Main {
  public static void main(String[] argv) {
    JFileChooser chooser = new JFileChooser();
    int result = chooser.showOpenDialog(null);
    switch (result) {
    case JFileChooser.APPROVE_OPTION:
      System.out.println("Approve (Open or Save) was clicked");
      break;
    case JFileChooser.CANCEL_OPTION:
      System.out.println("Cancel or the close-dialog icon was clicked");
      break;
    case JFileChooser.ERROR_OPTION:
      System.out.println("Error");
      break;
    }
  }
}