返回列表 發帖
  1. import javax.swing.JFrame;
  2. import javax.swing.JLabel;
  3. public class Ch79 {
  4.         public static void main(String[] args) {
  5.                 JFrame fm=new JFrame("標籤元件");
  6.             JLabel lb1=new JLabel("預設");
  7.             JLabel lb2=new JLabel("靠左");
  8.             JLabel lb3=new JLabel("置中",JLabel.CENTER);
  9.             JLabel lb4=new JLabel("靠右",JLabel.RIGHT);
  10.             JLabel lb5=new JLabel("其他");
  11.             fm.setBounds(100, 100, 200, 200);
  12.             fm.setVisible(true);
  13.             fm.setResizable(false);
  14.             fm.setLayout(null);
  15.             fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  16.             lb1.setBounds(10, 10, 180, 30);
  17.             lb2.setBounds(10, 40, 180, 30);
  18.             lb3.setBounds(10, 70, 180, 30);
  19.             lb4.setBounds(10, 100, 180, 30);
  20.             lb5.setBounds(10, 130, 180, 30);
  21.             fm.add(lb1);
  22.             fm.add(lb2);
  23.             fm.add(lb3);
  24.             fm.add(lb4);
  25.             fm.add(lb5);

  26.         }

  27. }
複製代碼

TOP

返回列表