Mega Code Archive

 
Categories / Java Tutorial / SWT
 

Suggest a file name to use for saving a file by prefilling the entry field in the Save dialog box

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 FileDialogSaveDefaultFileName {   public static void main(String[] args) {     Display display = new Display();     final Shell shell = new Shell(display);     FileDialog dlg = new FileDialog(shell, SWT.SAVE);     dlg.setFileName("defaultName");     String fileName = dlg.open();     if (fileName != null) {       System.out.println(fileName);     }     display.dispose();   } }