- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JTextField;
- public class Ch01
- {
- public static void main(String[] args)
- {
- JTextField t1=new JTextField();
- JTextField t2=new JTextField();
- JTextField t3=new JTextField();
- JLabel l1=new JLabel("輸入一");
- JLabel l2=new JLabel("輸入二");
- JLabel l3=new JLabel("輸入三");
- JFrame fm=new JFrame("JTextField配置練習");
- t1.setBounds(60, 10, 125, 30);
- t2.setBounds(60, 50, 125, 30);
- t2.setEnabled(false);
- t3.setBounds(60, 90, 125, 30);
- t3.setEditable(false);
- l1.setBounds(10, 10, 50, 30);
- l2.setBounds(10, 50, 50, 30);
- l3.setBounds(10, 90, 50, 30);
- fm.setBounds(100, 100, 200, 200);
- fm.setVisible(true);
- fm.setResizable(false);
- fm.setLayout(null);
- fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- fm.add(l1);
- fm.add(l2);
- fm.add(l3);
- fm.add(t1);
- fm.add(t2);
- fm.add(t3);
- }
- }
複製代碼 |