返回列表 發帖
  1. import javax.swing.JFrame;
  2. import javax.swing.JLabel;
  3. import javax.swing.JTextField;
  4. public class Ch01
  5. {
  6.         public static void main(String[] args)
  7.         {
  8.                 JTextField t1=new JTextField();
  9.                 JTextField t2=new JTextField();
  10.                 JTextField t3=new JTextField();
  11.                 JLabel l1=new JLabel("輸入一");
  12.                 JLabel l2=new JLabel("輸入二");
  13.                 JLabel l3=new JLabel("輸入三");
  14.                 JFrame fm=new JFrame("JTextField配置練習");
  15.                 t1.setBounds(60, 10, 125, 30);
  16.                 t2.setBounds(60, 50, 125, 30);
  17.                 t2.setEnabled(false);
  18.                 t3.setBounds(60, 90, 125, 30);
  19.                 t3.setEditable(false);
  20.                 l1.setBounds(10, 10, 50, 30);
  21.                 l2.setBounds(10, 50, 50, 30);
  22.                 l3.setBounds(10, 90, 50, 30);
  23.                 fm.setBounds(100, 100, 200, 200);
  24.                 fm.setVisible(true);
  25.                 fm.setResizable(false);
  26.                 fm.setLayout(null);
  27.                 fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  28.                 fm.add(l1);
  29.                 fm.add(l2);
  30.                 fm.add(l3);
  31.                 fm.add(t1);
  32.                 fm.add(t2);
  33.                 fm.add(t3);
  34.         }
  35. }
複製代碼
Ivy

TOP

返回列表