码迷,mamicode.com
首页 > 其他好文 > 详细

LayoutDemo

时间:2015-07-10 02:12:04      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:

 

技术分享

package swing.ui;

import java.awt.BorderLayout;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

/*2015-7-10*/
public class PanelLayoutTest extends JFrame {
    private static final long serialVersionUID = -2298874328963807208L;

    private JTextField
            name = new JTextField(),
            id = new JTextField();

    private JTextArea content = new JTextArea();

    public PanelLayoutTest() {
        this.setTitle("LayoutTest");
        this.setSize(600, 300);
        JPanel northPanel = new JPanel();
        northPanel.setLayout(new GridLayout(2, 2));
        northPanel.add(new JLabel("ID:"));
        northPanel.add(name);
        northPanel.add(new JLabel("Name:"));
        northPanel.add(id);

        this.add(northPanel, BorderLayout.NORTH);
        this.add(new JScrollPane(content), BorderLayout.CENTER);
        JPanel southPanel = new JPanel();
        southPanel.add(new JButton("Start"));
        this.add(southPanel, BorderLayout.SOUTH);
    }

    public static void main(String[] args) {
        PanelLayoutTest frame = new PanelLayoutTest();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
        frame.setLocationRelativeTo(null);
    }

}

 

LayoutDemo

标签:

原文地址:http://www.cnblogs.com/softidea/p/4634665.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!