- import javax.swing.JButton;
- import javax.swing.JFrame;
- public class Ch01 {
- public static void main(String args[])
- {
- JFrame f=new JFrame("元件配置練習");
- JButton b1=new JButton("按鈕一");
- JButton b2=new JButton("按鈕二");
-
- f.setBounds(100,100,220,220);
- f.setVisible(true);
- f.setResizable(false);
- f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- f.setLayout(null);
- f.add(b1);
- f.add(b2);
-
- b1.setBounds(10, 10, 175, 70);
- b1.setEnabled(false);
-
- b2.setBounds(10, 90, 175, 70);
- }
- }
複製代碼 |