1import org.eclipse.swt.SWT;
 2import org.eclipse.swt.widgets.Display;
 3import org.eclipse.swt.widgets.Label;
 4import org.eclipse.swt.widgets.Shell;
 5
 6/**
 7 * @author 糊涂鬼
 8 * Created on 2005-8-9 16:05:23
 9 */

10public class HelloWorld {
11
12    public static void main(String[] args) {
13        Display display = new Display();
14        Shell shell = new Shell(display);
15        Label label = new Label(shell,SWT.CENTER);
16        label.setText("Hello, World!!");
17        label.setBounds(shell.getClientArea());
18        shell.open();
19        while(!shell.isDisposed()){
20            if(!display.readAndDispatch()){
21                display.sleep();
22            }

23            // 這里是讓出來的控件停留一下,不加的話閃了一下后就消失了
24            try {
25                Thread.sleep(10000);
26            }
 catch (InterruptedException e) {
27                System.out.println(e.getMessage());
28            }

29            display.dispose();
30        }

31    }

32}
意圖很簡單的一個(gè)程序,因?yàn)槭堑谝粋€(gè)SWT程序嘛,就這樣運(yùn)行的話是會(huì)拋出異常的:
java.lang.UnsatisfiedLinkError: no swt-win32-3123 in java.library.path
....................................
at liltos.chp3.HelloWorld.main(HelloWord.java:13)
Exception in thread "main"
解決方法則是找到兩個(gè) .dll 文件,分別叫:swt-awt-win32-3064.dll,swt-win32-3064.dll,把這兩個(gè)東西復(fù)制到 win 系統(tǒng)目錄下的 system32 ,相信大多數(shù)人還是用的 Windows 吧。
這樣運(yùn)行成功一次后好像就可以了,再刪除的話也沒什么關(guān)系,一樣能夠正常運(yùn)行。

Swing 就不學(xué)了,誰讓他沒 SWT/JFace 強(qiáng)呢?既然是新學(xué),就選功能最強(qiáng)大的開始吧。其實(shí)也挺可惜的,Swing 類庫里的類我已經(jīng)了解得有一定數(shù)目,并且使用起來問題也不是很大了。這樣說丟就丟了,誒。