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


上面從左到右,從上到下,分別是包含的所有組件及其層次,組件的屬性設置區,“代碼/設計”標籤,工具,組件欄,對齊工具欄, 以及視圖區。下面是生成的代碼:

 

import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;


public class DialogTest extends Dialog {

	protected Object result;
	protected Shell shell;
	private Text text;

	/**
	 * Create the dialog.
	 * @param parent
	 * @param style
	 */
	public DialogTest(Shell parent, int style) {
		super(parent, style);
		setText("SWT Dialog");
	}

	/**
	 * Open the dialog.
	 * @return the result
	 */
	public Object open() {
		createContents();
		shell.open();
		shell.layout();
		Display display = getParent().getDisplay();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		return result;
	}

	/**
	 * Create contents of the dialog.
	 */
	private void createContents() {
		shell = new Shell(getParent(), getStyle());
		shell.setSize(450, 300);
		shell.setText(getText());
		
		Label lblUsername = new Label(shell, SWT.NONE);
		lblUsername.setBounds(114, 71, 58, 12);
		lblUsername.setText("UserName");
		
		text = new Text(shell, SWT.BORDER);
		text.setBounds(185, 68, 71, 18);

	}
}
 

看上去還不錯吧!

 

參考資料:http://www.blogjava.net/pengo/archive/2010/09/19/332482.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章