返回列表 發帖
  1. import javax.swing.JFrame;
  2. import javax.swing.JLabel;

  3. public class Ch76 {

  4.         public static void main(String[] args) {
  5.                 JFrame fm=new JFrame("元件配置練習");
  6.         JLabel lb1=new JLabel("預設");
  7.         JLabel lb2=new JLabel("靠左",JLabel.LEFT);
  8.         JLabel lb3=new JLabel("置中",JLabel.CENTER);
  9.         JLabel lb4=new JLabel("靠右",JLabel.RIGHT);
  10.         JLabel lb5=new JLabel("其他");
  11.         
  12.         lb1.setBounds(8, 0, 180, 30);
  13.         lb2.setBounds(8, 35, 180, 30);
  14.         lb3.setBounds(8, 70, 180, 30);
  15.         lb4.setBounds(8, 105, 180, 30);
  16.         lb5.setBounds(50, 140, 180, 30);
  17.         
  18.                 fm.setBounds(100, 100, 200, 200);
  19.                 fm.setVisible(true);
  20.                 fm.setResizable(false);
  21.                 fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  22.                 fm.setLayout(null);
  23.                 fm.add(lb1);
  24.                 fm.add(lb2);
  25.                 fm.add(lb3);
  26.                 fm.add(lb4);
  27.                 fm.add(lb5);

  28.         }

  29. }
複製代碼

TOP

返回列表