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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值