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