返回列表 發帖
  1. import javax.swing.JFrame;
  2. import javax.swing.JButton;
  3. import java.awt.BorderLayout;
  4. public class Ch01 {
  5.         JFrame fm;
  6.         JButton b1,b2,b3,b4,b5,b6;
  7.         Ch01()
  8.         {
  9.                 b1=new JButton("xxx");
  10.                 b2=new JButton("xxxxxxx");
  11.                 b3=new JButton("xxxxxxxxxxx");
  12.                 b4=new JButton("xxxxxxxxx    xxxxxxx");
  13.                 b5=new JButton("xxx");            
  14.                 fm=new JFrame("BorderLayout");
  15.                 fm.setBounds(100, 100, 300, 200);
  16.                 fm.setVisible(true);
  17.                 fm.setResizable(true);
  18.                 fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  19.                 fm.setLayout(new BorderLayout(5,5));
  20.                 fm.add(b1, BorderLayout.NORTH);
  21.                 fm.add(b2, BorderLayout.SOUTH);
  22.                 fm.add(b3, BorderLayout.WEST);
  23.                 fm.add(b4, BorderLayout.CENTER);
  24.                 fm.add(b5, BorderLayout.EAST);
  25.         }     
  26.         public static void main(String[] args) {
  27.                 new Ch01();
  28.         }
  29. }
複製代碼
Ivy

TOP

返回列表