###### 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); } } ``` >顯示結果 >   >不管怎麼放大縮小視窗,他都會變成置中型態
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up