Package de.soldin.awt
Class VerticalFlowLayout
- java.lang.Object
-
- de.soldin.awt.VerticalFlowLayout
-
- All Implemented Interfaces:
LayoutManager,Serializable
public class VerticalFlowLayout extends Object implements LayoutManager, Serializable
This flow layout arranges components in a directional flow, much like lines of text in a paragraph but vertically. The flow direction is determined by the container'scomponentOrientationproperty and may be one of two values:ComponentOrientation.LEFT_TO_RIGHTComponentOrientation.RIGHT_TO_LEFT
We arrange components vertically until no more components fit on the same column. The vertical alignment is determined by the
alignproperty. The possible values are:See
main() methodin source code for an example on how to use it.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intBOTTOMThis value indicates that each column of components should be bottom-justified.static intCENTERThis value indicates that each column of components should be centered.static intHEIGHTstatic intTOPThis value indicates that each column of components should be top-justified.static intWIDTH
-
Constructor Summary
Constructors Constructor Description VerticalFlowLayout()Constructs a newVerticalFlowLayoutwith a centered alignment and a default 5-unit horizontal and vertical gap.VerticalFlowLayout(int align)Constructs a newVerticalFlowLayoutwith 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLayoutComponent(String name, Component comp)Adds the specified component to the layout.intgetAlignment()Gets the alignment for this layout.doublegetDefaultRatio()intgetHgap()Gets the horizontal gap between components and between the components and the borders of theContainerintgetVgap()Gets the vertical gap between components and between the components and the borders of theContainer.intgetWrapMode()Sets the wrap mode for this layoutvoidlayoutContainer(Container target)Lays out the container.static voidmain(String[] args)DimensionminimumLayoutSize(Container target)Returns the minimum dimensions needed to layout the visible components contained in the specified target container.DimensionpreferredLayoutSize(Container target)Returns the preferred dimensions for this layout given the visible components in the specified target container.voidremoveLayoutComponent(Component comp)Removes the specified component from the layout.voidsetAlignment(int align)Sets the alignment for this layout.voidsetDefaultRatio(double defRatio)Set a default layout ratio.voidsetHgap(int hgap)Sets the horizontal gap between components and between the components and the borders of theContainer.voidsetVgap(int vgap)Sets the vertical gap between components and between the components and the borders of theContainer.voidsetWrapMode(int wrapMode)Sets the alignment for this layout.StringtoString()Returns a string representation of thisVerticalFlowLayoutobject and its values.
-
-
-
Field Detail
-
TOP
public static final int TOP
This value indicates that each column of components should be top-justified.- See Also:
- Constant Field Values
-
CENTER
public static final int CENTER
This value indicates that each column of components should be centered.- See Also:
- Constant Field Values
-
BOTTOM
public static final int BOTTOM
This value indicates that each column of components should be bottom-justified.- See Also:
- Constant Field Values
-
WIDTH
public static final int WIDTH
- See Also:
- Constant Field Values
-
HEIGHT
public static final int HEIGHT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
VerticalFlowLayout
public VerticalFlowLayout()
Constructs a newVerticalFlowLayoutwith a centered alignment and a default 5-unit horizontal and vertical gap.
-
VerticalFlowLayout
public VerticalFlowLayout(int align)
Constructs a newVerticalFlowLayoutwith the specified alignment and a default 5-unit horizontal and vertical gap. The value of the alignment argument must be one ofVerticalFlowLayout.TOP,VerticalFlowLayout.BOTTOM, orVerticalFlowLayout.CENTER- Parameters:
align- the alignment value
-
VerticalFlowLayout
public VerticalFlowLayout(int align, int hgap, int vgap)Creates a new flow layout manager with the indicated alignment and the indicated horizontal and vertical gaps.The value of the alignment argument must be one of
VerticalFlowLayout.TOP,VerticalFlowLayout.BOTTOM, orVerticalFlowLayout.CENTER.- Parameters:
align- the alignment valuehgap- the horizontal gap between components and between the components and the borders of theContainervgap- the vertical gap between components and between the components and the borders of theContainer
-
-
Method Detail
-
getAlignment
public int getAlignment()
Gets the alignment for this layout. Possible values areVerticalFlowLayout.TOP,VerticalFlowLayout.BOTTOMorVerticalFlowLayout.CENTER,- Returns:
- the alignment value for this layout
- See Also:
FlowLayout.setAlignment(int)
-
setAlignment
public void setAlignment(int align)
Sets the alignment for this layout. Possible values areVerticalFlowLayout.TOPVerticalFlowLayout.BOTTOMVerticalFlowLayout.CENTER
- Parameters:
align- one of the alignment values shown above- See Also:
getAlignment()
-
getWrapMode
public int getWrapMode()
Sets the wrap mode for this layout- Returns:
- int wrap mode
-
setWrapMode
public void setWrapMode(int wrapMode)
Sets the alignment for this layout. Possible values areVerticalFlowLayout.WIDTH(default)VerticalFlowLayout.HEIGHT
- Parameters:
wrapMode- wrap mode to use : WIDTH (default) or HEIGHT
-
getDefaultRatio
public double getDefaultRatio()
-
setDefaultRatio
public void setDefaultRatio(double defRatio)
Set a default layout ratio. SeedefRatiocomment above.- Parameters:
defRatio- default ratio (width/height)
-
getHgap
public int getHgap()
Gets the horizontal gap between components and between the components and the borders of theContainer- Returns:
- the horizontal gap between components and between the components
and the borders of the
Container - Since:
- JDK1.1
- See Also:
FlowLayout.setHgap(int)
-
setHgap
public void setHgap(int hgap)
Sets the horizontal gap between components and between the components and the borders of theContainer.- Parameters:
hgap- the horizontal gap between components and between the components and the borders of theContainer- Since:
- JDK1.1
- See Also:
FlowLayout.getHgap()
-
getVgap
public int getVgap()
Gets the vertical gap between components and between the components and the borders of theContainer.- Returns:
- the vertical gap between components and between the components and
the borders of the
Container - Since:
- JDK1.1
- See Also:
FlowLayout.setVgap(int)
-
setVgap
public void setVgap(int vgap)
Sets the vertical gap between components and between the components and the borders of theContainer.- Parameters:
vgap- the vertical gap between components and between the components and the borders of theContainer- See Also:
FlowLayout.getVgap()
-
addLayoutComponent
public void addLayoutComponent(String name, Component comp)
Adds the specified component to the layout. Not used by this class.- Specified by:
addLayoutComponentin interfaceLayoutManager- Parameters:
name- the name of the componentcomp- the component to be added
-
removeLayoutComponent
public void removeLayoutComponent(Component comp)
Removes the specified component from the layout. Not used by this class.- Specified by:
removeLayoutComponentin interfaceLayoutManager- Parameters:
comp- the component to remove- See Also:
Container.removeAll()
-
preferredLayoutSize
public Dimension preferredLayoutSize(Container target)
Returns the preferred dimensions for this layout given the visible components in the specified target container.- Specified by:
preferredLayoutSizein interfaceLayoutManager- Parameters:
target- the container that needs to be laid out- Returns:
- the preferred dimensions to lay out the subcomponents of the specified container
- See Also:
Container,minimumLayoutSize(java.awt.Container),Container.getPreferredSize()
-
minimumLayoutSize
public Dimension minimumLayoutSize(Container target)
Returns the minimum dimensions needed to layout the visible components contained in the specified target container. Not supported by this class! ReturnspreferredLayoutSize(Container)instead.- Specified by:
minimumLayoutSizein interfaceLayoutManager
-
layoutContainer
public void layoutContainer(Container target)
Lays out the container. This method lets each visible component take its preferred size by reshaping the components in the target container in order to satisfy the alignment of thisVerticalFlowLayoutobject.- Specified by:
layoutContainerin interfaceLayoutManager- Parameters:
target- the specified component being laid out- See Also:
Container,Container.doLayout()
-
toString
public String toString()
Returns a string representation of thisVerticalFlowLayoutobject and its values.
-
main
public static void main(String[] args)
-
-