SWT 入门之 -> HelloWorld

 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}

意图很简单的一个程序,因为是第一个SWT程序嘛,就这样运行的话是会抛出异常的:
java.lang.UnsatisfiedLinkError: no swt-win32-3123 in java.library.path

Exception in thread "main"
解决方法则是找到两个 .dll 文件,分别叫:swt-awt-win32-3064.dll,swt-win32-3064.dll,把这两个东西复制到 win 系统目录下的 system32 ,相信大多数人还是用的 Windows 吧。
这样运行成功一次后好像就可以了,再删除的话也没什么关系,一样能够正常运行。

Swing 就不学了,谁让他没 SWT/JFace 强呢?既然是新学,就选功能最强大的开始吧。其实也挺可惜的,Swing 类库里的类我已经了解得有一定数目,并且使用起来问题也不是很大了。这样说丢就丢了,诶。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值