Creating a File Chooser Dialog - Java Swing

Java examples for Swing:JFileChooser

Description

Creating a File Chooser Dialog

Demo Code

import java.io.File;

import javax.swing.JFileChooser;
import javax.swing.JFrame;

public class Main {
  public static void main(String[] args) {
    String filename = File.separator + "tmp";
    JFileChooser fc = new JFileChooser(new File(filename));
    JFrame frame = null;/*from   w w w. java  2 s  .c o  m*/
    // Open file dialog.
    fc.showOpenDialog(frame);

    // Save file dialog.
    fc.showSaveDialog(frame);

  }
}

Related Tutorials