Contents | Package | Class | Tree | Deprecated | Index | Help | Java 1.2 Beta 3 | ||
PREV | NEXT | SHOW LISTS | HIDE LISTS |
java.lang.Object | +----java.awt.FlowLayout
For example, the following picture shows an applet using the flow layout manager (its default layout manager) to position three buttons:
Here is the code for this 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); } }
A flow layout lets each component assume its natural (preferred) size.
Field Summary | |
static int | CENTER
|
static int | LEFT
|
static int | RIGHT
|
Constructor Summary | |
FlowLayout()
|
|
FlowLayout(int align)
|
|
FlowLayout(int align,
int hgap,
int vgap)
|
Method Summary | |
void | addLayoutComponent(String name,
Component comp)
|
int | getAlignment()
|
int | getHgap()
|
int | getVgap()
|
void | layoutContainer(Container target)
|
Dimension | minimumLayoutSize(Container target)
|
Dimension | preferredLayoutSize(Container target)
|
void | removeLayoutComponent(Component comp)
|
void | setAlignment(int align)
|
void | setHgap(int hgap)
|
void | setVgap(int vgap)
|
String | toString()
FlowLayout
object and its values.
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int LEFT
public static final int CENTER
public static final int RIGHT
Constructor Detail |
public FlowLayout()
public FlowLayout(int align)
FlowLayout.LEFT
, FlowLayout.RIGHT
,
or FlowLayout.CENTER
.
align
- the alignment value
public FlowLayout(int align, int hgap, int vgap)
The value of the alignment argument must be one of
FlowLayout.LEFT
, FlowLayout.RIGHT
,
or FlowLayout.CENTER
.
align
- the alignment value.
hgap
- the horizontal gap between components.
vgap
- the vertical gap between components.
Method Detail |
public int getAlignment()
FlowLayout.LEFT
,
FlowLayout.RIGHT
, or FlowLayout.CENTER
.public void setAlignment(int align)
FlowLayout.LEFT
,
FlowLayout.RIGHT
, and FlowLayout.CENTER
.
align
- the alignment value.
public int getHgap()
public void setHgap(int hgap)
hgap
- the horizontal gap between components
public int getVgap()
public void setVgap(int vgap)
vgap
- the vertical gap between components
public void addLayoutComponent(String name, Component comp)
name
- the name of the component
comp
- the component to be added
public void removeLayoutComponent(Component comp)
comp
- the component to remove
public Dimension preferredLayoutSize(Container target)
target
- the component which needs to be laid out
public Dimension minimumLayoutSize(Container target)
target
- the component which needs to be laid out
public void layoutContainer(Container target)
FlowLayout
object.
target
- the specified component being laid out.
public String toString()
FlowLayout
object and its values.Contents | Package | Class | Tree | Deprecated | Index | Help | Java 1.2 Beta 3 | ||
PREV | NEXT | SHOW LISTS | HIDE LISTS |