JPanel面板
package com.chen.lesson5;
import javax.swing.*;
import java.awt.*;
public class JPanelDemo extends JFrame {
public JPanelDemo() {
Container container = this.getContentPane();
container.setLayout(new GridLayout(2,1,10,10));
JPanel jPanel = new JPanel(new GridLayout(2,1));
JPanel jPane2 = new JPanel(new GridLayout(1,2));
JPanel jPane3 = new JPanel(new GridLayout(3,1));
JPanel jPane4 = new JPanel(new GridLayout(1,3));
jPanel.add(new JButton("1"));
jPanel.add(new JButton("1"));
jPane2.add(new JButton("2"));
jPane2.add(new JButton("2"));
jPane3.add(new JButton("3"));
jPane3.add(new JButton("3"));
jPane3.add(new JButton("3"));
jPane4.add(new JButton("4"));
jPane4.add(new JButton("4"));
jPane4.add(new JButton("4"));
container.add(jPanel);
container.add(jPane2);
container.add(jPane3);
container.add(jPane4);
this.setVisible(true);
this.setBounds(200,200,800,800);
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new JPanelDemo();
}
}