1
import org.eclipse.swt.SWT;
2
import org.eclipse.swt.widgets.Display;
3
import org.eclipse.swt.widgets.Label;
4
import org.eclipse.swt.widgets.Shell;
5
6
/**//**
7
* @author 糊涂鬼
8
* Created on 2005-8-9 16:05:23
9
*/
10
public 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
}

2

3

4

5

6


7

8

9

10



11

12



13

14

15

16

17

18

19



20



21

22

23

24



25

26



27

28

29

30

31

32

java.lang.UnsatisfiedLinkError: no swt-win32-3123 in java.library.path
....................................
at liltos.chp3.HelloWorld.main(HelloWord.java:13)
Exception in thread "main"
解決方法則是找到兩個 .dll 文件,分別叫:swt-awt-win32-3064.dll,swt-win32-3064.dll,把這兩個東西復制到 win 系統目錄下的 system32 ,相信大多數人還是用的 Windows 吧。
這樣運行成功一次后好像就可以了,再刪除的話也沒什么關系,一樣能夠正常運行。
Swing 就不學了,誰讓他沒 SWT/JFace 強呢?既然是新學,就選功能最強大的開始吧。其實也挺可惜的,Swing 類庫里的類我已經了解得有一定數目,并且使用起來問題也不是很大了。這樣說丟就丟了,誒。