WindowBuilder安装与简单使用

由于emf,gef,ve,Eclipse可视化插件最多支持都eclectic3.2版本,现在使用受到了限制。


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...



新建JFrame






生成的代码也很干净

package ustc;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.UIManager;
import javax.swing.SwingConstants;
import javax.swing.DropMode;

public class DengLu extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JTextField textField_1;
	private JTextField Note;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					DengLu frame = new DengLu();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public DengLu() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 327);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		contentPane.setLayout(null);  //这里设置为null了

		JLabel label = new JLabel("\u7528\u6237\u540D");
		label.setBounds(79, 33, 54, 15);
		contentPane.add(label);

		textField = new JTextField();
		textField.setBounds(143, 30, 206, 21); //手动代码控制控件大小
		contentPane.add(textField);
		textField.setColumns(10);

		JLabel label_1 = new JLabel("\u5BC6  \u7801");
		label_1.setBounds(79, 89, 54, 15);
		contentPane.add(label_1);

		textField_1 = new JTextField();
		textField_1.setBounds(143, 86, 206, 21);
		contentPane.add(textField_1);
		textField_1.setColumns(10);

		JButton btnNe = new JButton("\u767B\u9646");
		btnNe.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if ( (textField.getText().equalsIgnoreCase("a")) && (textField_1.getText().equalsIgnoreCase("a"))){
				//if ( (textField.getText() == "a") && (textField_1.getText() == "a"){		这个代码回出错,一直是否		
					textField.setText("");
					textField_1.setText("");
					Note.setText("欢迎登陆成功");
				}else{
					textField.setText("");
					textField_1.setText("");
					Note.setText("注意,用户名和密码都是a,不区分大小写。");
				}
			}
		});
		btnNe.setBounds(107, 155, 93, 23);
		contentPane.add(btnNe);

		JButton button_1 = new JButton("\u5173\u95ED");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				textField.setText("");
				textField_1.setText("");
				Note.setText("关闭窗口");
			}
		});
		button_1.setBounds(243, 155, 93, 23);
		contentPane.add(button_1);
		
		Note = new JTextField();
		Note.setToolTipText("Welcome");
		Note.setHorizontalAlignment(SwingConstants.LEFT);
		contentPane.add(Note, BorderLayout.SOUTH);
		//Note.setBounds(143, 86, 206, 21);
		Note.setBounds(57, 200, 330, 50);
		//Note.setColumns(10);
	}

}

参考资料:

http://www.blogjava.net/pengo/archive/2010/09/19/332482.html

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值