import java.awt.*;
import javax.swing.*;
public class UsuallyJFrame extends JFrame{
//定义
JPanel jp1,jp2;
JButton jb[] = null;
public static void main(String[] args) {
UsuallyJFrame UJ = new UsuallyJFrame();
}
//创建
public UsuallyJFrame() {
jp1 = new JPanel();
jp2 = new JPanel();
jb[0] = new JButton("西瓜");
jb[1] = new JButton("南瓜");
jb[2] = new JButton("东瓜");
jb[3] = new JButton("木瓜");
jb[4] = new JButton("丝瓜");
jb[5] = new JButton("地瓜");
jb[6] = new JButton("歪瓜");
//设置布局
jp1.add(jb[0]);
jp1.add(jb[1]);
jp1.add(jb[2]);
jp2.add(jb[3]);
jp2.add(jb[4]);
jp2.add(jb[5]);
//把panel加入到JFrame
this.add(jp1,BorderLayout.NORTH);
this.add(jb[6],BorderLayout.CENTER);
this.add(jp2,BorderLayout.SOUTH);
this.setSize(300, 300);
this.setLocation(200, 150);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}