(英文原文:http://www.eclipse.org/swt/faq.php)
翻译:Frank(frank@zijinshi.cn)
版本:Version 0.9
The SWT FAQ
-
11.问: 怎样用Java Web Start 配置独立的 SWT 应用?
-
答:如果你想一步步的学会怎样用Java Web Start(JSW)打包、配置SWT应用,你可以参见这篇文章
How to deploy SWT Applications with Java Web Start. 还有一篇相关的文章(但是这篇文章没有描述如何用JWS配置SWT应用)
http://www-106.ibm.com/developerworks/opensource/library/os-jws/.
注意:在 eclipse 3.3上,你不能通过JWS在Mac OS X 上配置SWT 客户端。(参见 bug 63306).
12.问:如果我想在 PocketPC 上运行 SWT,我该如何做呢?
-
答:在WinCE设备上,有一个SWT的试验版。如果你想尝试一下,可以通过如下的步骤开始:
- 在 PocketPC 上安装 虚拟机(VM)。
他已经在ARM WinCE PocketPC上用J9 VM测试过。- 想知道如何得到 J9 VM, 请参见WebSphere Studio Device Developer网站 (它包括J9):
http://www.embedded.oti.com/wdd - 想知道如何使用J9 VM, 请参见WebSphere 新闻组:
ibm.software.websphere.studio.device-developer
- 想知道如何得到 J9 VM, 请参见WebSphere Studio Device Developer网站 (它包括J9):
- 得到用于PocketPC的 swt.jar 和 SWT dll。 参见 Where is the SWT library for the PocketPC?
- 把文件 swt.jar 和 SWT dll 复制到设备中。
- 把SWT应用程序复制到设备中。
For example, compile the following class inside Eclipse and copy the resulting class file to your device. 例如,在Eclipse中完成如下程序,并把编译的class文件复制到设备中。import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
public class HelloWorld {
public static void main(String[] args) {
Display display = new Display();
/*
* Create a Shell with the default style
* i.e. full screen, no decoration on PocketPC.
* Alternative: 'new Shell(display, SWT.CLOSE)'
* to get the Pocket PC 'Ok' button.
*/
Shell shell = new Shell(display);
/*
* Set a text so that the top level Shell
* also appears in the Pocket PC task list
*/
shell.setText("HelloWorld");
/*
* Set a menubar to follow UI guidelines
* on Pocket PC
*/
Menu mb = new Menu(shell, SWT.BAR);
shell.setMenuBar(mb);
/*
* Add widgets
*/
FillLayout layout = new FillLayout();
layout.type = SWT.VERTICAL;
shell.setLayout(layout);
Label label = new Label(shell, SWT.CENTER);
label.setText("Hello World");
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
} - 运行SWT应用。
有种方法是创建一个快捷方式,通过它来打开:- 在桌面上,创建一个文件 'HelloWorld.lnk'。 在快捷方式的命令中插入以下行:
68#/j9/bin/j9.exe -Djava.home=/j9
-cp:/java/swt.jar;/java HelloWorld前提是假设你的J9 VM安装在文件夹 /j9 中,并且你已经把swt.jar 和 HelloWorld.class 复制到目录 /java。也假设 SWT dll 已经复制到目录 /j9/bin,放在这个文件夹里 VM 可以找到它。
- 保存快捷方式,并把它复制到设备中。
- 使用设备中的文件夹浏览器,点击快捷方式文件。
如果一切都安装正确的话,那么SWT应用就会运行。
- 在桌面上,创建一个文件 'HelloWorld.lnk'。 在快捷方式的命令中插入以下行:
- 在 PocketPC 上安装 虚拟机(VM)。
(待续…)