java Swing可視化開發工具


Eclipse中比較出名的2個插件是:

Visual Editor 和windowbuilder。現在VE好像過時了,只支持3.2的版本。那就用windowbuilder吧。官網:

http://www.eclipse.org/windowbuilder/

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按鈕

單擊確定后,就可以在列表中看到相關的安裝文件。點擊next一路安裝下去。

安裝完成后,重啟Eclipse,點擊File→New→Project...

新建JFrame

 

 

生成的代碼:

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;


public class MianFrame extends JFrame {

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

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
        } catch (Throwable e) {
            e.printStackTrace();
        }
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    MianFrame frame = new MianFrame();
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the frame.
     */
    public MianFrame() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 450, 300);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(contentPane);
        contentPane.setLayout(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) {
            }
        });
        btnNe.setBounds(107, 155, 93, 23);
        contentPane.add(btnNe);
        
        JButton button_1 = new JButton("\u5173\u95ED");
        button_1.setBounds(243, 155, 93, 23);
        contentPane.add(button_1);
    }
}

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM