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.Label;
import org.eclipse.swt.widgets.Shell;
public class ButtonTest {
/**
* Launch the application
* @param args
*/
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(500, 375);
shell.setText("SWT Application");
//
shell.open();
final Button sButton = new Button(shell, SWT.NONE);
sButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
System.exit(0);
}
});
sButton.setText("exit");
sButton.setBounds(128, 173, 85, 22);
sButton.setToolTipText("点击退出");
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
posted on 2008-03-31 07:08
hakuci 阅读(282)
评论(0) 编辑 收藏