当前位置 类层次 (JDK) 所有类 (JDK) 所有域和方法 (JDK)

类 java.awt.FlowLayout

java.lang.Object
   |
   +----java.awt.FlowLayout

public class FlowLayout
extends Object
implements LayoutManager, Serializable

流布局在一个 left-to-right 流中安排组件,很象在段落中的文本行。 流布局特别常用于在面板中安排按钮。 它会从左到右的安排按钮直到在同一行中不可以再放置更多的按钮时为止。 每行都是中心对齐的。

例如,下列画面显示出一个 applet 使用流布局管理器(它的缺省布局管理器) 来放置三个按钮:

Graphic of Layout for Three Buttons

这里是该 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);
     }
 }
 

流布局使每个组件呈现它的自然(首选的)大小。


变量索引

CENTER
该数值表示每个组件行应当被中心对齐。
LEFT
该数值表示每个组件行应当被向左对齐。
RIGHT
该数值表示每个组件行应当被向右对齐。

构造子索引

FlowLayout()
用中心对齐方式和缺省为 5-unit 的水平垂直间隙来构造一个新的 Flow Layout 。
FlowLayout(int)
用特定的对齐方式和缺省为 5-unit 的水平垂直间隙来构造一个新的 Flow Layout 。
FlowLayout(int, int, int)
用指定的对齐方式和指定的水平垂直间隙来构造一个新的 Flow Layout 。

方法索引

addLayoutComponent(String, Component)
将指定的组件添加到布局。
getAlignment()
获取该布局的对齐方式。
getHgap()
获取两个组件之间的水平间隙。
getVgap()
获取两个组件之间的垂直间隙。
layoutContainer(Container)
布局容器。
minimumLayoutSize(Container)
返回布局包含在特定目标容器中的组件所需的最小尺寸。
preferredLayoutSize(Container)
返回布局包含在特定目标容器中的组件的首选尺寸。
removeLayoutComponent(Component)
从布局中删除特定组件。
setAlignment(int)
设置该布局的对齐方式。
setHgap(int)
设置两个组件之间的水平间隙。
setVgap(int)
设置两个组件之间的垂直间隙。
toString()
返回表示该 FlowLayout 对象和它的值的字符串。

变量

LEFT
 public static final int LEFT
该数值表示每个组件行应当被向左对齐。

CENTER
 public static final int CENTER
该数值表示每个组件行应当被中心对齐。

RIGHT
 public static final int RIGHT
该数值表示每个组件行应当被向右对齐。


构造子

FlowLayout
 public FlowLayout()
用中心对齐方式和缺省为 5-unit 的水平垂直间隙来构造一个新的 Flow Layout 。

FlowLayout
 public FlowLayout(int align)
用特定的对齐方式和缺省为 5-unit 的水平垂直间隙来构造一个新的 Flow Layout 。 对齐方式参数的值必须是 FlowLayout.LEFTFlowLayout.RIGHT ,或 FlowLayout.CENTER 中的一个。

参数:
align - 对齐值
FlowLayout
 public FlowLayout(int align,
                   int hgap,
                   int vgap)
用指定的对齐方式和指定的水平垂直间隙来构造一个新的 Flow Layout 。

对齐方式参数的值必须是 FlowLayout.LEFTFlowLayout.RIGHT ,或 FlowLayout.CENTER 中的一个。

参数:
align - 对齐值。
hgap - 两个组件之间的水平间隙。
vgap - 两个组件之间的垂直间隙。

方法

getAlignment
 public int getAlignment()
获取该布局的对齐方式。 可能值为 FlowLayout.LEFTFlowLayout.RIGHT ,或 FlowLayout.CENTER

返回值:
该布局的对齐值。
参见:
setAlignment
setAlignment
 public void setAlignment(int align)
设置该布局的对齐方式。 可能值为 FlowLayout.LEFTFlowLayout.RIGHT ,和 FlowLayout.CENTER

参数:
align - 对齐值。
参见:
getAlignment
getHgap
 public int getHgap()
获取两个组件之间的水平间隙。

返回值:
两个组件之间的水平间隙。
参见:
setHgap
setHgap
 public void setHgap(int hgap)
设置两个组件之间的水平间隙。

参数:
hgap - 两个组件之间的水平间隙
参见:
getHgap
getVgap
 public int getVgap()
获取两个组件之间的垂直间隙。

返回值:
两个组件之间的垂直间隙。
参见:
setVgap
setVgap
 public void setVgap(int vgap)
设置两个组件之间的垂直间隙。

参数:
vgap - 两个组件之间的垂直间隙
参见:
getVgap
addLayoutComponent
 public void addLayoutComponent(String name,
                                Component comp)
将特定的组件添加到布局。 这个类不使用它。

参数:
name - 组件名
comp - 要添加的组件
removeLayoutComponent
 public void removeLayoutComponent(Component comp)
从布局中删除特定组件。 这个类不使用它。

参数:
comp - 要删除的组件
参见:
removeAll
preferredLayoutSize
 public Dimension preferredLayoutSize(Container target)
返回布局包含在指定目标容器中的组件的首选尺寸。

参数:
target - 要布局的组件
返回值:
要布局到特定容器的子组件的首选尺寸。
参见:
Container, minimumLayoutSize, getPreferredSize
minimumLayoutSize
 public Dimension minimumLayoutSize(Container target)
返回布局包含在特定目标容器中的组件所需的最小尺寸。

参数:
target - 要布局的组件
返回值:
要布局到特定容器的子组件的最小尺寸。
参见:
preferredLayoutSize, Container, doLayout
layoutContainer
 public void layoutContainer(Container target)
布局容器。 该方法使每个组件通过调整在目标容器中组件来取得它的首选尺寸,从而满足该 FlowLayout 对象的限制。

参数:
target - 特定的将被布局的组件。
参见:
Container, doLayout
toString
 public String toString()
返回表示该 FlowLayout 对象和它的值的字符串。

返回值:
表示该布局的字符串。
覆盖:
Object 中的 toString

当前位置 类层次 (JDK) 所有类 (JDK) 所有域和方法 (JDK)