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