Java JFileChooser .showSaveDialog (Component parent)

Syntax

JFileChooser.showSaveDialog(Component parent) has the following syntax.

public int showSaveDialog(Component parent)   throws HeadlessException

Example

In the following code shows how to use JFileChooser.showSaveDialog(Component parent) method.


//from w  ww  .j  av  a  2s  . c  o  m
import javax.swing.JFileChooser;

public class Main {

  public static void main(String[] a) {

    JFileChooser fileChooser = new JFileChooser();

    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    fileChooser.showSaveDialog(null);
  }

}