importorg.eclipse.jface.dialogs.MessageDialog;importorg.eclipse.swt.SWT;importorg.eclipse.swt.events.SelectionAdapter;importorg.eclipse.swt.events.SelectionEvent;importor...
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class HelloWorld {
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(327, 253);
shell.setText("Hello World");
Button button = new Button(shell, SWT.NONE);
button.setText("确定");
button.setBounds(88, 94, 100, 25);
button.addSelectionListener(new SelectionAdapter() {
public void windgetSelected(SelectionEvent e) {
MessageDialog.openInformation(shell,"hello","helloworld");
}
});
shell.layout();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
展开