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

  35.         }

  36. }
複製代碼

TOP

返回列表