返回列表 發帖
  1. import javax.swing.*;
  2. public class Ch100 {
  3.         public static void main(String[] args) {

  4.                 JTextField tf1=new JTextField();
  5.                 JTextField tf2=new JTextField();
  6.                 JTextField tf3=new JTextField();
  7.                 JLabel lb1=new JLabel("輸入一");
  8.                 JLabel lb2=new JLabel("輸入二");
  9.                 JLabel lb3=new JLabel("輸入三");
  10.                 JFrame fm=new JFrame("JTextField配置練習");

  11.                 tf1.setBounds(60, 10, 125, 30);
  12.                 tf2.setBounds(60, 50, 125, 30);
  13.                 tf2.setEnabled(false);
  14.                 tf3.setBounds(60, 90, 125, 30);
  15.                 tf3.setEditable(false);

  16.                 lb1.setBounds(10, 10, 50, 30);
  17.                 lb2.setBounds(10, 50, 50, 30);
  18.                 lb3.setBounds(10, 90, 50, 30);

  19.                 fm.setBounds(100, 100, 200, 200);
  20.                 fm.setVisible(true);
  21.                 fm.setResizable(false);
  22.                 fm.setLayout(null);
  23.                 fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  24.                 fm.add(lb1);
  25.                 fm.add(lb2);
  26.                 fm.add(lb3);
  27.                 fm.add(tf1);
  28.                 fm.add(tf2);
  29.                 fm.add(tf3);
  30.         }
  31. }
複製代碼

TOP

返回列表