---
# System prepended metadata

title: Java自學紀錄 - 版面配置
tags: [Java]

---

###### tags: `Java`
# Java自學紀錄 - 版面配置
# FlowLatout 類別
* FlowLayout() 預設物件置中對齊,各物件垂直與水平間間距5單位
* FlowLayout(int align,int hgap,int vgap)
align 對齊方式
hgap 水平間距
vgap 垂直間距

```java=
package learning.AWT;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Java_14_Layout extends Frame {
    Label lb1 = new Label("Lable1");
    Label lb2 = new Label("Lable2");
    Label lb3 = new Label("Lable3");
    Label lb4 = new Label("Lable4");
    Label lb5 = new Label("Lable5");
    Label lb6 = new Label("Lable6");
    Java_14_Layout(){
        this.setSize(500,500);
        FlowLayout layout = new FlowLayout();
        this.setLayout(layout);
        this.add(lb1);
        this.add(lb2);
        this.add(lb3);
        this.add(lb4);
        this.add(lb5);
        this.add(lb6);
    }

    public static void main(String[] args) {
        Java_14_Layout frm = new Java_14_Layout();
        frm.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        frm.setVisible(true);
    }
}
```
>顯示結果
>
![](https://i.imgur.com/Y6U36ug.png)
![](https://i.imgur.com/i78wzCb.png)

>不管怎麼放大縮小視窗,他都會變成置中型態