- import java.awt.BorderLayout;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- public class Ch130 {
- JFrame fn;
- JButton btn1, btn2, btn3, btn4, btn5, btn6;
-
- Ch130()
- {
- btn1 = new JButton("xxx");
- btn2 = new JButton("xxxxxxx");
- btn3 = new JButton("xxxxxxxxxxx");
- btn4 = new JButton("xxxxxxxxx xxxxxxx");
- btn5 = new JButton("xxx");
- //btn6 = new JButton("x");
-
- fn = new JFrame("Grid");
- fn.setBounds(100, 100, 300, 200);
- fn.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- fn.setVisible(true);
- fn.setLayout(new BorderLayout(5, 5));
- fn.add(btn1, BorderLayout.NORTH);
- fn.add(btn2, BorderLayout.SOUTH);
- fn.add(btn3, BorderLayout.EAST);
- fn.add(btn4, BorderLayout.WEST);
- fn.add(btn5, BorderLayout.CENTER);
- //fn.add(btn6);
- }
- public static void main(String[] args) {
- new Ch130();
- }
- }
複製代碼 |