public class VerticalFlowLayout
extends java.lang.Object
implements java.awt.LayoutManager, java.io.Serializable
componentOrientation property and may be one of
two values:
ComponentOrientation.LEFT_TO_RIGHT
ComponentOrientation.RIGHT_TO_LEFT
We arrange components vertically until no more components fit on the same
column. The vertical alignment is determined by the align
property. The possible values are:
See main() method in source code for an example on how to use
it.
| Modifier and Type | Field and Description |
|---|---|
static int |
BOTTOM
This value indicates that each column of components should be
bottom-justified.
|
static int |
CENTER
This value indicates that each column of components should be centered.
|
static int |
HEIGHT |
static int |
TOP
This value indicates that each column of components should be
top-justified.
|
static int |
WIDTH |
| Constructor and Description |
|---|
VerticalFlowLayout()
Constructs a new
VerticalFlowLayout with a centered alignment
and a default 5-unit horizontal and vertical gap. |
VerticalFlowLayout(int align)
Constructs a new
VerticalFlowLayout with the specified
alignment and a default 5-unit horizontal and vertical gap. |
VerticalFlowLayout(int align,
int hgap,
int vgap)
Creates a new flow layout manager with the indicated alignment and the
indicated horizontal and vertical gaps.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLayoutComponent(java.lang.String name,
java.awt.Component comp)
Adds the specified component to the layout.
|
int |
getAlignment()
Gets the alignment for this layout.
|
double |
getDefaultRatio() |
int |
getHgap()
Gets the horizontal gap between components and between the components and
the borders of the
Container |
int |
getVgap()
Gets the vertical gap between components and between the components and the
borders of the
Container. |
int |
getWrapMode()
Sets the wrap mode for this layout
|
void |
layoutContainer(java.awt.Container target)
Lays out the container.
|
static void |
main(java.lang.String[] args) |
java.awt.Dimension |
minimumLayoutSize(java.awt.Container target)
Returns the minimum dimensions needed to layout the visible
components contained in the specified target container.
|
java.awt.Dimension |
preferredLayoutSize(java.awt.Container target)
Returns the preferred dimensions for this layout given the visible
components in the specified target container.
|
void |
removeLayoutComponent(java.awt.Component comp)
Removes the specified component from the layout.
|
void |
setAlignment(int align)
Sets the alignment for this layout.
|
void |
setDefaultRatio(double defRatio)
Set a default layout ratio.
|
void |
setHgap(int hgap)
Sets the horizontal gap between components and between the components and
the borders of the
Container. |
void |
setVgap(int vgap)
Sets the vertical gap between components and between the components and the
borders of the
Container. |
void |
setWrapMode(int wrapMode)
Sets the alignment for this layout.
|
java.lang.String |
toString()
Returns a string representation of this
VerticalFlowLayout
object and its values. |
public static final int TOP
public static final int CENTER
public static final int BOTTOM
public static final int WIDTH
public static final int HEIGHT
public VerticalFlowLayout()
VerticalFlowLayout with a centered alignment
and a default 5-unit horizontal and vertical gap.public VerticalFlowLayout(int align)
VerticalFlowLayout with the specified
alignment and a default 5-unit horizontal and vertical gap. The value of
the alignment argument must be one of VerticalFlowLayout.TOP,
VerticalFlowLayout.BOTTOM, or
VerticalFlowLayout.CENTERalign - the alignment valuepublic VerticalFlowLayout(int align,
int hgap,
int vgap)
The value of the alignment argument must be one of
VerticalFlowLayout.TOP, VerticalFlowLayout.BOTTOM
, or VerticalFlowLayout.CENTER.
align - the alignment valuehgap - the horizontal gap between components and between the components
and the borders of the Containervgap - the vertical gap between components and between the components and
the borders of the Containerpublic int getAlignment()
VerticalFlowLayout.TOP, VerticalFlowLayout.BOTTOM
or VerticalFlowLayout.CENTER,java.awt.VerticalFlowLayout#setAlignmentpublic void setAlignment(int align)
VerticalFlowLayout.TOP
VerticalFlowLayout.BOTTOM
VerticalFlowLayout.CENTER
align - one of the alignment values shown abovegetAlignment()public int getWrapMode()
public void setWrapMode(int wrapMode)
VerticalFlowLayout.WIDTH (default)
VerticalFlowLayout.HEIGHT
wrapMode - public double getDefaultRatio()
public void setDefaultRatio(double defRatio)
defRatio comment above.defRatio - public int getHgap()
ContainerContainerjava.awt.VerticalFlowLayout#setHgappublic void setHgap(int hgap)
Container.hgap - the horizontal gap between components and between the components
and the borders of the Containerjava.awt.VerticalFlowLayout#getHgappublic int getVgap()
Container.Containerjava.awt.VerticalFlowLayout#setVgappublic void setVgap(int vgap)
Container.vgap - the vertical gap between components and between the components and
the borders of the Containerjava.awt.VerticalFlowLayout#getVgappublic void addLayoutComponent(java.lang.String name,
java.awt.Component comp)
addLayoutComponent in interface java.awt.LayoutManagername - the name of the componentcomp - the component to be addedpublic void removeLayoutComponent(java.awt.Component comp)
removeLayoutComponent in interface java.awt.LayoutManagercomp - the component to removeContainer.removeAll()public java.awt.Dimension preferredLayoutSize(java.awt.Container target)
preferredLayoutSize in interface java.awt.LayoutManagertarget - the container that needs to be laid outContainer,
minimumLayoutSize(java.awt.Container),
Container.getPreferredSize()public java.awt.Dimension minimumLayoutSize(java.awt.Container target)
preferredLayoutSize(Container) instead.minimumLayoutSize in interface java.awt.LayoutManagerpublic void layoutContainer(java.awt.Container target)
VerticalFlowLayout
object.layoutContainer in interface java.awt.LayoutManagertarget - the specified component being laid outContainer,
Container.doLayout()public java.lang.String toString()
VerticalFlowLayout
object and its values.toString in class java.lang.Objectpublic static void main(java.lang.String[] args)