FileDialog: prompt for a file name (to save) : File Dir Chooser « SWT JFace Eclipse « Java

FileDialog: prompt for a file name (to save)

FileDialog: prompt for a file name (to save)

 * FileDialog example snippet: prompt for a file name (to save)
 * For a list of all SWT example snippets see
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;

public class Snippet72 {

  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);;
    FileDialog dialog = new FileDialog(shell, SWT.SAVE);
        .setFilterNames(new String[] { "Batch Files", "All Files (*.*)" });
    dialog.setFilterExtensions(new String[] { "*.bat", "*.*" }); // Windows
                                    // wild
                                    // cards
    dialog.setFilterPath("c:\\"); // Windows path
    System.out.println("Save to: " +;
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())


Related examples in the same category

1.Dir File SelectionDir File Selection
2.File ViewerFile Viewer
3.DirectoryDialog: prompt for a directoryDirectoryDialog: prompt for a directory