返回列表 發帖
  1. import javax.swing.JFrame;
  2. import javax.swing.JButton;
  3. import java.awt.GridLayout;
  4. public class Ch114 {
  5.       
  6.         JFrame fm;
  7.         JButton btn1,btn2,btn3,btn4,btn5,btn6;
  8.         Ch114()
  9.         {
  10.                 JButton btn1=new JButton("xxx");
  11.                 JButton btn2=new JButton("xxxxxxx");
  12.                 JButton btn3=new JButton("xxxxxxxxxxx");
  13.                 JButton btn4=new JButton("xxxxxxxxx    xxxxxxx");
  14.                 JButton btn5=new JButton("xxx");
  15.                 JButton btn6=new JButton("x");
  16.                
  17.                 fm=new JFrame("GridLayout");
  18.                 fm.setBounds(100, 100, 300, 200);
  19.                 fm.setVisible(true);
  20.                 fm.setResizable(true);
  21.                 fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  22.                 fm.setLayout(new GridLayout(3,2,5,5));            
  23.                 fm.add(btn1);
  24.                 fm.add(btn2);
  25.                 fm.add(btn3);
  26.                 fm.add(btn4);
  27.                 fm.add(btn5);
  28.                 fm.add(btn6);
  29.         }
  30.       
  31.         public static void main(String[] args) {
  32.                 new Ch114();
  33.         }
  34. }
複製代碼
七日不見 如隔一周

TOP

返回列表