開發者 | Eclipse基金會 |
---|---|
当前版本 |
|
源代码库 | |
操作系统 | 跨平台 |
语言 | 多語言 |
类型 | Java平臺部件工具箱 |
许可协议 | Eclipse公共授權 |
网站 | www |
SWT(Standard Widget Toolkit),最初由IBM开发的一套用于Java的图形用户界面系统,用来与Swing竞争。
开源整合開發環境Eclipse就是用Java和SWT开发的。
下列為基本使用SWT的Hello World程式。顯示出一個視窗(Shell)及一個標籤。
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
public class HelloWorld
{
public static void main (String[] args)
{
Display display = new Display();
Shell shell = new Shell(display);
Label label = new Label(shell, SWT.NONE);
label.setText("Hello World");
label.pack();
shell.pack();
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
}