使用WindowBuilder在Eclipse上创建GUI

时间:2014-10-10 23:05:14

标签: java swing windowbuilder

我几乎不会在Java中创建GUI。我很久以前就使用过Jigloo,但是我做了一个非常简单的GUI。

我需要一些创建工具栏的指导(例如文件,选项,帮助等)和带有显示其值的编辑框的滑块?我几乎熟悉标签,编辑框。

一般来说,我想构建一个类似这样的GUI:

enter image description here

我使用jFrame的简单代码如下:

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.JToolBar;

public class ControlPanel {

    private JFrame frame;

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

    /**
     * Create the application.
     */
    public ControlPanel() {
        initialize();
    }

    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        frame = new JFrame();
//      frame.sets
        frame.setBounds(100, 100, 1000, 600);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().setLayout(null);

        JToolBar toolBar = new JToolBar();
        toolBar.setBounds(10, 11, 87, 16);
        frame.getContentPane().add(toolBar);

        JPanel panel = new JPanel();
        panel.setBounds(10, 38, 400, 100);
        frame.getContentPane().add(panel);
        panel.setLayout(null);

        JPanel panel_1 = new JPanel();
        panel_1.setBounds(10, 149, 400, 100);
        frame.getContentPane().add(panel_1);
        panel_1.setLayout(null);

        JSlider slider = new JSlider();
        slider.setBounds(0, 11, 400, 26);
        panel_1.add(slider);

        JPanel panel_2 = new JPanel();
        panel_2.setBounds(10, 260, 400, 100);
        frame.getContentPane().add(panel_2);

        JPanel panel_3 = new JPanel();
        panel_3.setBounds(10, 371, 400, 100);
        frame.getContentPane().add(panel_3);
    }

}

0 个答案:

没有答案