FlowLayout
流佈局用於安排有向流中的組件,這非常類似於段落中的文本行。流的方向取決於容器的
componentOrientation
屬性,
ComponentOrientation.LEFT_TO_RIGHT
ComponentOrientation.RIGHT_TO_LEFT
- 流佈局一般用來安排面板中的按鈕。它使得按鈕呈水平放置,直到同一條線上再也沒有適合的按鈕。線的對齊方式由
align
屬性確定。可能的值爲:LEFT 左
RIGHT 右
CENTER 居中
LEADING 與容器方向的開始邊對齊,例如,對於從左到右的方向,則與左邊對齊
TRAILING 與容器方向的結束邊對齊,例如,對於從左到右的方向,則與右邊對齊
import java.applet.Applet;
public class myButtons extends Applet {
Button button1, button2, button3;
public void init() {
button1 = new Button("Ok");
button2 = new Button("Open");
button3 = new Button("Close");
Label b=new Label("標籤");
add(button1);
add(button2);
add(button3);
add(b);
}
}