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

  3. public class Ch01 {
  4.         public static void main(String args[])
  5.         {
  6.                 JLabel l1=new JLabel("預設");
  7.                 l1.setBounds(10, 10, 180, 20);
  8.                
  9.                 JLabel l2=new JLabel("靠左",JLabel.LEFT);
  10.                 l2.setBounds(10, 40, 180, 20);
  11.                
  12.                 JLabel l3=new JLabel("置中",JLabel.CENTER);
  13.                 l3.setBounds(10, 70, 180, 20);
  14.                
  15.                 JLabel l4=new JLabel("靠右",JLabel.RIGHT);
  16.                 l4.setBounds(10, 100, 180, 20);
  17.                
  18.                 JLabel l5=new JLabel("其他");
  19.                 l5.setBounds(80, 100, 180, 50);
  20.                            
  21.             JFrame f=new JFrame("JLabel");
  22.             f.setBounds(100,100,250,250);
  23.             f.setVisible(true);
  24.             f.setResizable(false);
  25.             f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  26.             f.setLayout(null);
  27.             f.add(l1);
  28.             f.add(l2);
  29.             f.add(l3);
  30.             f.add(l4);
  31.             f.add(l5);
  32.             
  33.         }
  34. }
複製代碼

TOP

返回列表