• LayoutDemo


    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);
        }
    
    }
  • 相关阅读:
    网页添加提示音
    poj 2593和poj 2479
    HDU 1558 Segment set
    Ubuntu中conky的安装配置
    Codeforce C. Buns
    HDU 3952 Fruit Ninja
    IE8,IE9,IE10,FireFox 的CSS HACK
    HDU 1086 You can Solve a Geometry Problem too
    Ubuntu中Cairo Dock安装和设置
    Ubuntu 12.04 中安装和配置 Java JDK(转)
  • 原文地址:https://www.cnblogs.com/softidea/p/4634665.html
Copyright © 2020-2023  润新知