package com.utstar.factory;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
/**
* GridLayout布局管理器是設定行*列的布局,中途可以增加行或列數,按照添加控件的順序從左至右從上至下來添加
* 可以設定整體行列之間的間隔,不能跨行跨列,適用於控件布局類似棋盤的樣式。
* @author HZ20232
*
*/
public class TestGridLayout extends JFrame{
private static final long serialVersionUID = 6819222900970457455L;
private JButton button1;
private JButton button2;
private JButton button3;
private JButton button4;
private JButton button5;
private JButton button6;
public TestGridLayout(){
this.setSize(600,400);
this.setTitle("測試");
init();
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public void init(){
button1 = new JButton("NORTH");
button2 = new JButton("SOUTH");
button3 = new JButton("EAST");
button4 = new JButton("WEST");
button5 = new JButton("CENTER");
button6 = new JButton("CENTER6");
GridLayout myLayout = new GridLayout(2,3);
myLayout.setHgap(10);
myLayout.setVgap(10);
this.setLayout(myLayout);
this.add(button1);
this.add(button2);
this.add(button3);
this.add(button4);
this.add(button5);
this.add(button6);
}
public static void main(String args[]){
TestGridLayout test = new TestGridLayout();
}
}
*