返回列表 發帖
  1. import javax.swing.JFrame;
  2. import javax.swing.JLabel;
  3. public class Ch01
  4. {
  5.         public static void main(String[] args)
  6.         {
  7.                 JFrame fm=new JFrame("元件配置練習");
  8.                 JLabel l1=new JLabel("預設");
  9.                 JLabel l2=new JLabel("靠左",JLabel.LEFT);
  10.                 JLabel l3=new JLabel("置中",JLabel.CENTER);
  11.                 JLabel l4=new JLabel("靠右",JLabel.RIGHT);
  12.                 JLabel l5=new JLabel("其他");
  13.                 l1.setBounds(8, 0, 180, 30);
  14.                 l2.setBounds(8, 35, 180, 30);
  15.                 l3.setBounds(8, 70, 180, 30);
  16.                 l4.setBounds(8, 105, 180, 30);
  17.                 l5.setBounds(50, 140, 100, 30);   
  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(l1);
  24.                 fm.add(l2);
  25.                 fm.add(l3);
  26.                 fm.add(l4);
  27.                 fm.add(l5);
  28.         }
  29. }
複製代碼
Ivy

TOP

返回列表