转自:
http://blog.youkuaiyun.com/lingdushanke/article/details/5145507
一、在Eclipse中安装SWT插件swt designer
根据 eclipse 版本的不同,下载不同的 SWT-Desiger. 下载地址: http://www.swt-designer.com/
安装方法和所有的 eclipse 插件一样,将 features, plugins 下的文件放到 eclipse 相应的文件夹中就好了,重启 eclipse, OK .
[color=red](在eclipse3.6里面没有找到preferences->Designer选项,下面这个步骤跳过了,经检验依然可以正确开发SWT程序)[/color]
二、破解插件
eclipse->windows->preferences->Designer –Registration and Activation ->SWT Designer Professional Paid ->next-> 输入相关的信息 ->next 在 serial Number 和 Activation Key 输入注册码。注册机的下载地址:
http://www.blogjava.net/Files/zjuedsion/解压并且修改好的破解工具.rar
next 就 OK 了。
三、创建SWT工程
在Eclipse中文件-新建-其它,找到WindowBulider-SWT/JFace Java Project,创建一个已经导入了SWT库的工程
四、生成一个SWT窗口的一般步骤
1、创建一个或多个 Shell
2、设置 Shell 的布局
3、创建 Shell 中的的组件(注:本例还没有加入组件,只是一个空窗口)
4、用 open() 方法打开 Shell 窗口
5、写一个事件转发循环
6、销毁 display
helloword程序示例:
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class SWTTest {
public static void main(String[] args)
{
final Display display=Display.getDefault();
final Shell shell=new Shell();
shell.setSize(400, 300);
shell.setText("First SWT");
shell.layout();
Label label=new Label(shell,SWT.SHADOW_IN);
label.setText("hello world!");
label.pack();
shell.open();
while(!shell.isDisposed())
{
if(!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
http://blog.youkuaiyun.com/lingdushanke/article/details/5145507
一、在Eclipse中安装SWT插件swt designer
根据 eclipse 版本的不同,下载不同的 SWT-Desiger. 下载地址: http://www.swt-designer.com/
安装方法和所有的 eclipse 插件一样,将 features, plugins 下的文件放到 eclipse 相应的文件夹中就好了,重启 eclipse, OK .
[color=red](在eclipse3.6里面没有找到preferences->Designer选项,下面这个步骤跳过了,经检验依然可以正确开发SWT程序)[/color]
二、破解插件
eclipse->windows->preferences->Designer –Registration and Activation ->SWT Designer Professional Paid ->next-> 输入相关的信息 ->next 在 serial Number 和 Activation Key 输入注册码。注册机的下载地址:
http://www.blogjava.net/Files/zjuedsion/解压并且修改好的破解工具.rar
next 就 OK 了。
三、创建SWT工程
在Eclipse中文件-新建-其它,找到WindowBulider-SWT/JFace Java Project,创建一个已经导入了SWT库的工程
四、生成一个SWT窗口的一般步骤
1、创建一个或多个 Shell
2、设置 Shell 的布局
3、创建 Shell 中的的组件(注:本例还没有加入组件,只是一个空窗口)
4、用 open() 方法打开 Shell 窗口
5、写一个事件转发循环
6、销毁 display
helloword程序示例:
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class SWTTest {
public static void main(String[] args)
{
final Display display=Display.getDefault();
final Shell shell=new Shell();
shell.setSize(400, 300);
shell.setText("First SWT");
shell.layout();
Label label=new Label(shell,SWT.SHADOW_IN);
label.setText("hello world!");
label.pack();
shell.open();
while(!shell.isDisposed())
{
if(!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}