本来是想安装Visual Editor的,但是资料上提供的网址已经无法使用了,在网上搜了一些帖子,并不是很好用。但是也不是没有收获,无意中看到有人说Visual Editor已经停止维护了,不如用WindowBuilder!
于是搜了关于WindowBuilder的资料,
WindowBuilder - is a powerful and easy to use bi-directional Java GUI designer
WindowBuilder is composed of SWT Designer and Swing Designer and makes it very easy to create Java GUI applications without spending a lot of time writing code. Use the WYSIWYG visual designer and layout tools to create simple forms to complex windows; the Java code will be generated for you. Easily add controls using drag-and-drop, add event handlers to your controls, change various properties of controls using a property editor, internationalize your app and much more.
Happy accident!有了它,swing/swt也可以像visual studio一样拖拉控件写程序。
安装地址:http://www.eclipse.org/windowbuilder/download.php
根据eclipse的版本来选择合适的版本,我的是4.3版本。
打开Eclipse,打开菜单Help→Install New Software,单击Work with后的Add按钮,输入与你Eclipse对应版本的更新地址,我的是4.3版本。
http://download.eclipse.org/windowbuilder/WB/release/R201406251200/4.3/
这里有详细的安装说明。
安装完成后,重启Eclipse,点击File→New→Project,选择WindowBuilder→SWT Designer→SWT/JFace Java Project
给你的工程命名
在src目录下,新建包,命名为pkg。右击pkg,new→other。
创建一个Application Window程序,SWT Designer→SWT→Application Window,命名为Helloworld
点击finish后,Eclipse就会自动生成窗口类的代码:
点击Design,就可以进入可视化设计了:
给选择一个按钮控件,拖进窗口中:
双击按钮,可以进入Source查看生成的代码:
参考资料
Eclipse地址:http://www.eclipse.org/downloads/
WindowBuilder安装地址:http://www.eclipse.org/windowbuilder/download.php