複製鏈接
請複製以下鏈接發送給好友

FlowLayout

鎖定
FlowLayout(int align, int hgap, int vgap)創建一個新的流佈局管理器,它具有指定的對齊方式以及指定的水平和垂直間隙,用於JAVA語言的圖形化界面設計。 align 參數的值必須是以下值之一:FlowLayout.LEFT、FlowLayout.RIGHT、FlowLayout.CENTER、FlowLayout.LEADING 或 FlowLayout.TRAILING。
軟件名稱
FlowLayout
別    名
int align, int hgap, int vgap
類    型
FlowLayout流佈局管理器

FlowLayout軟件介紹

java.awt.FlowLayout
所有已實現的接口:
LayoutManager, Serializable public class FlowLayoutextends Objectimplements LayoutManager, Serializable流佈局用於安排有向流中的組件,這非常類似於段落中的文本行。流的方向取決於容器的 componentOrientation 屬性,它可能是以下兩個值中的一個:
ComponentOrientation.LEFT_TO_RIGHTComponentOrientation.RIGHT_TO_LEFT流佈局一般用來安排面板中的按鈕。它使得按鈕呈水平放置,直到同一條線上再也沒有適合的按鈕。線的對齊方式由 align 屬性確定。可能的值為: LEFT RIGHT CENTER LEADING TRAILING例如,以下圖片顯
以下是此 applet 的代碼:
import java.awt.*;
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");
add(button1);
add(button2);
add(button3);
}
}
字段摘要
static int
此值指示每一行組件都應該是居中的。
static int
此值指示每一行組件都應該與容器方向的開始邊對齊,例如,對於從左到右的方向,則與左邊對齊。
static int
此值指示每一行組件都應該是左對齊的。
static int
RIGHT
此值指示每一行組件都應該是右對齊的。
static int
此值指示每行組件都應該與容器方向的結束邊對齊,例如,對於從左到右的方向,則與右邊對齊。
構造方法摘要
FlowLayout()
構造一個新的 FlowLayout,它是居中對齊的,默認的水平和垂直間隙是 5 個單位。
FlowLayout(int align)
構造一個新的 FlowLayout,它具有指定的對齊方式,默認的水平和垂直間隙是 5 個單位。
FlowLayout(int align, int hgap, int vgap)
創建一個新的流佈局管理器,它具有指定的對齊方式以及指定的水平和垂直間隙。
方法摘要
void
addLayoutComponent(String name, Component comp)
將指定的組件添加到佈局中。
int
getAlignment()
獲取此佈局的對齊方式。
boolean
getAlignOnBaseline()
如果組件將沿其基線垂直對齊,則返回 true。
int
getHgap()
獲取組件之間以及組件與 Container 的邊之間的水平間隙。
int
getVgap()
獲取組件之間以及組件與 Container 的邊之間的垂直間隙。
void
layoutContainer(Container target)
佈置該容器。
minimumLayoutSize(Container target)
返回需要佈置 visible 組件的最小維數,該組件包含在指定的目標容器中。
preferredLayoutSize(Container target)
給出指定目標容器中的 visible 組件,返回此佈局的首選維數。
void
removeLayoutComponent(Component comp)
從佈局中移除指定的組件。
void
setAlignment(int align)
設置此佈局的對齊方式。
void
setAlignOnBaseline(boolean alignOnBaseline)
設置組件是否應該沿着其基線垂直對齊。
void
setHgap(int hgap)
設置組件之間以及組件與 Container 的邊之間的水平間隙。
void
setVgap(int vgap)
設置組件之間以及組件與 Container 的邊之間的垂直間隙。
String
返回此 FlowLayout 對象及其值的字符串表示形式。
從類 java.lang.Object繼承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
LEFT
public static final int LEFT此值指示每一行組件都應該是左對齊的。 另請參見:常量字段值
CENTER
public static final int CENTER此值指示每一行組件都應該是居中的。 另請參見:常量字段值
RIGHT
public static final int RIGHT此值指示每一行組件都應該是右對齊的。 另請參見:常量字段值
LEADING
public static final int LEADING此值指示每一行組件都應該與容器方向的開始邊對齊,例如,對於從左到右的方向,則與左邊對齊。 從以下版本開始:1.2 另請參見:Component.getComponentOrientation( ), ComponentOrientation, 常量字段值
TRAILING
public static final int TRAILING此值指示每行組件都應該與容器方向的結束邊對齊,例如,對於從左到右的方向,則與右邊對齊。 從以下版本開始:1.2 另請參見:Component.getComponentOrientation( ), ComponentOrientation, 常量字段值

FlowLayout構造方法

FlowLayout
public FlowLayout( )構造一個新的 FlowLayout,它是居中對齊的,默認的水平和垂直間隙是 5 個單位。
FlowLayout
public FlowLayout(int align)構造一個新的 FlowLayout,它具有指定的對齊方式,默認的水平和垂直間隙是 5 個單位。align 參數的值必須是以下值之一:FlowLayout.LEFT、FlowLayout.RIGHT、FlowLayout.CENTER、FlowLayout.LEADING 或 FlowLayout.TRAILING。 參數:align - 對齊值
FlowLayout
public FlowLayout(int align, int hgap, int vgap)創建一個新的流佈局管理器,它具有指定的對齊方式以及指定的水平和垂直間隙。 align 參數的值必須是以下值之一:FlowLayout.LEFT、FlowLayout.RIGHT、FlowLayout.CENTER、FlowLayout.LEADING 或 FlowLayout.TRAILING。
參數:align - 對齊值hgap - 組件之間以及組件與 Container 的邊之間的水平間隙vgap - 組件之間以及組件與 Container 的邊之間的垂直間隙