GroupLayout 是一個 LayoutManager
每個組可以包含任意數量的元素
GroupLayout是一個很重要的是額布局管理器
GroupLayout必須要設置它的GroupLayout
GroupLayout
GroupLayout
GroupLayout
大概就是按照這個順序去添加
然後就設置到GroupLayout
下面的實例
/**
* @author
* @date
* @place
*/
import javax
import javax
import javax
import javax
import javax
import javax
import javax
public class MyFrame extends javax
public static void main(String[] args) {
MyFrame f = new MyFrame();
}
JLabel label
JLabel label
JLabel label
JTextField tf;
JPasswordField psf;
JRadioButton rb
JRadioButton rb
JButton bt
JButton bt
public MyFrame() {
this
this
this
this
label
label
label
tf = new JTextField();
psf = new JPasswordField();
rb
rb
bt
// 為指定的 Container 創建 GroupLayout
GroupLayout layout = new GroupLayout(this
this
//創建GroupLayout的水平連續組
GroupLayout
hGroup
hGroup
hGroup
hGroup
hGroup
layout
//創建GroupLayout的垂直連續組
GroupLayout
vGroup
vGroup
vGroup
vGroup
vGroup
vGroup
vGroup
vGroup
vGroup
vGroup
//設置垂直組
layout
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26010.html