打开一个文件打开FileDialog
Display display = new Display();
Shell shell = new Shell(SWT.ON_TOP);
FileDialog fileChooser = new FileDialog(shell, SWT.OPEN);
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 FileDialogOpenSelectedName {
public static void main(String[] args) {
Display display = new Display();
final Shell shell = new Shell(display);
FileDialog dlg = new FileDialog(shell, SWT.OPEN);
String fileName = dlg.open();
if (fileName != null) {
System.out.println(fileName);
}
display.dispose();
}
}
|
http://www.java2v.com/CN/Tutorial/Java/0280__SWT/OpenanOpenFileDialog.htm