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


  3. public class label
  4. {

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

  30.         }

  31. }
複製代碼

TOP

返回列表