返回列表 發帖
  1. package ch05;

  2. import javax.swing.JFrame;
  3. import javax.swing.JLabel;

  4. public class ch06 {

  5.         public static void main(String[] args) {
  6.         JFrame fm=new JFrame("視窗");
  7.         JLabel l1=new JLabel("預設");
  8.         JLabel l2=new JLabel("置中",JLabel.CENTER);
  9.         JLabel l3=new JLabel("靠右",JLabel.RIGHT);
  10.         JLabel l4=new JLabel("靠左",JLabel.LEFT);
  11.         JLabel l5=new JLabel("其他");
  12.        
  13.         l1.setBounds(8, 0, 180, 30);
  14.         l2.setBounds(8, 30, 180, 30);
  15.         l3.setBounds(8, 60, 180, 30);
  16.         l4.setBounds(8, 90, 180, 30);
  17.         l5.setBounds(50, 120, 180, 30);
  18.        
  19.         fm.setBounds(100, 100, 200, 200);
  20.         fm.setVisible(true);
  21.         fm.setLayout(null);
  22.         fm.setResizable(true);
  23.         fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  24.         fm.add(l2);
  25.         fm.add(l1);
  26.         fm.add(l3);
  27.         fm.add(l4);
  28.         fm.add(l5);
  29.         }

  30. }
複製代碼

TOP

返回列表