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

  4. public class Ch01 {
  5.         public static void main(String args[])
  6.         {
  7.                 JLabel l1=new JLabel("輸入一");
  8.                 l1.setBounds(10, 20, 180, 20);
  9.                 JLabel l2=new JLabel("輸入二");
  10.                 l2.setBounds(10, 60, 180, 20);
  11.                 JLabel l3=new JLabel("輸入三");
  12.                 l3.setBounds(10, 100, 180, 20);

  13.                 JTextField t1=new JTextField();
  14.                 t1.setBounds(60, 15, 120, 30);
  15.                 JTextField t2=new JTextField();
  16.                 t2.setBounds(60, 55, 120, 30);
  17.                 t2.setEnabled(false);
  18.                 JTextField t3=new JTextField();
  19.                 t3.setBounds(60, 95, 120, 30);
  20.                 t3.setEditable(false);

  21.                 JFrame f=new JFrame("JTextField配置練習");
  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(t1);
  31.                 f.add(t2);
  32.                 f.add(t3);

  33.         }
  34. }
複製代碼

TOP

返回列表