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