- import javax.swing.JButton;
- import javax.swing.JFrame;
- public class Ch76 {
- public static void main(String[] args) {
- JFrame fm = new JFrame("button");
- 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);
- }
- }
複製代碼 |