返回列表 發帖
  1. import javax.swing.JFrame;
  2. import javax.swing.JLabel;
  3. public class Ch01 {
  4.         public static void main(String[] args) {
  5.        
  6.                 JFrame f=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, 35, 180, 30);
  14.                 l3.setBounds(8, 70, 180, 30);
  15.                 l4.setBounds(8, 105, 180, 30);
  16.                 l5.setBounds(50, 140, 100, 30);
  17.                 f.setBounds(100, 100, 200, 200);
  18.                 f.setVisible(true);
  19.                 f.setResizable(false);
  20.                 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  21.                 f.setLayout(null);
  22.                 f.add(l1);
  23.                 f.add(l2);
  24.                 f.add(l3);
  25.                 f.add(l4);
  26.                 f.add(l5);
  27.         }
  28. }
複製代碼
Allen

TOP

返回列表