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

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

  29.         }

  30. }
複製代碼
李宇澤Oscar

TOP

返回列表