IT精英-请移步http://www.ithtu.com
分类: Java
2007-08-09 17:38:23
public class FlowLayout
流布局用于安排有向流中的组件,这非常类似于段落中的文本行。流的方向取决于容器的 componentOrientation
属性,它可能是以下两个值中的一个:
ComponentOrientation.LEFT_TO_RIGHT
ComponentOrientation.RIGHT_TO_LEFT
align
属性确定。可能的值为:
例如,以下图片显示了使用流布局管理器(它的默认布局管理器)来定位三个按钮的 applet:
以下是此 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); } }
流布局把每个组件都假定为它的自然(首选)大小。