返回列表 發帖
  1. import javax.swing.JFrame;
  2. import javax.swing.JLabel;
  3. public class Ch09 {

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

  27.         }

  28. }
複製代碼
hahahahahahahaha

TOP

返回列表