WindowBuilder,SWT可视化工具(免费)

windowbuilder,也就是原来的SWT Designer。Google收购了Instantiations,把它的工具也重新免费发布了。
用过swt designer的人都知它是非常好用的swing/swt可视化开发工具,有了它,swing/swt也可以像visual studio一样拖拉控件写程序(虽然netbean也可以,不过没怎用),可惜是个收费产品,后来把改名为windowbuilder。不过Google把这个工具的开发公司Instantiations收购了,并把这个产品免费发布。Google收购Instantiations是为了给它的GWT设计开发工具,据说也是为了它的Anroid搞开发工具(......)。
安装地址:http://code.google.com/intl/zh-CN/webtoolkit/tools/download-wbpro.html
安装windowbuilder很方便,不过通过Eclipse的Update方式安装这个插件,eclipse的windowbuilder更新地址:
Eclipse 3.6 (Helios)
http://dl.google.com/eclipse/inst/d2wbpro/latest/3.6
Eclipse 3.5 (Galileo)
http://dl.google.com/eclipse/inst/d2wbpro/latest/3.5
Eclipse 3.4 (Ganymede)
http://dl.google.com/eclipse/inst/d2wbpro/latest/3.4

打开Eclipse,打开菜单Help→Install New Software,单击Work with后的Add按钮,输入与你Eclipse对应版本的更新地址,我的是3.5版本



单击确定后,就可以在列表中看到相关的安装文件。点击next一路安装下去。

安装完成后,重启Eclipse,点击File→New→Project...



 然后下一步


之后生成的工程如下:


然后新建dialog如下:



然后查看生成的Dialog


上面从左到右,从上到下,分别是包含的所有组件及其层次,组件的属性设置区,“代码/设计”标签,工具,组件栏,对齐工具栏, 以及视图区。下面是生成的代码:

Java代码  收藏代码
  1. import org.eclipse.swt.widgets.Dialog;  
  2. import org.eclipse.swt.widgets.Display;  
  3. import org.eclipse.swt.widgets.Shell;  
  4. import org.eclipse.swt.widgets.Label;  
  5. import org.eclipse.swt.SWT;  
  6. import org.eclipse.swt.widgets.Text;  
  7.   
  8.   
  9. public class DialogTest extends Dialog {  
  10.   
  11.     protected Object result;  
  12.     protected Shell shell;  
  13.     private Text text;  
  14.   
  15.     /** 
  16.      * Create the dialog. 
  17.      * @param parent 
  18.      * @param style 
  19.      */  
  20.     public DialogTest(Shell parent, int style) {  
  21.         super(parent, style);  
  22.         setText("SWT Dialog");  
  23.     }  
  24.   
  25.     /** 
  26.      * Open the dialog. 
  27.      * @return the result 
  28.      */  
  29.     public Object open() {  
  30.         createContents();  
  31.         shell.open();  
  32.         shell.layout();  
  33.         Display display = getParent().getDisplay();  
  34.         while (!shell.isDisposed()) {  
  35.             if (!display.readAndDispatch()) {  
  36.                 display.sleep();  
  37.             }  
  38.         }  
  39.         return result;  
  40.     }  
  41.   
  42.     /** 
  43.      * Create contents of the dialog. 
  44.      */  
  45.     private void createContents() {  
  46.         shell = new Shell(getParent(), getStyle());  
  47.         shell.setSize(450300);  
  48.         shell.setText(getText());  
  49.           
  50.         Label lblUsername = new Label(shell, SWT.NONE);  
  51.         lblUsername.setBounds(114715812);  
  52.         lblUsername.setText("UserName");  
  53.           
  54.         text = new Text(shell, SWT.BORDER);  
  55.         text.setBounds(185687118);  
  56.   
  57.     }  
  58. }  

 

看上去还不错吧!

原文地址:https://www.cnblogs.com/jianming-chan/p/3265464.html