net.wotonomy.ui.swing.components
Class BetterFlowLayout

java.lang.Object
  extended by java.awt.FlowLayout
      extended by net.wotonomy.ui.swing.components.BetterFlowLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.io.Serializable

public class BetterFlowLayout
extends java.awt.FlowLayout

BetterFlowLayout works just like FlowLayout, except that you can specify a vertical orientation in addition to the usual horizontal orientations. You can also specify that all the components be sized to the same height and/or width. By default, the behavior is identical to FlowLayout.

Version:
$Revision: 904 $ $Date: 2006-02-18 23:19:05 +0000 (Sat, 18 Feb 2006) $
Author:
michael@mpowers.net, $Author: cgruber $
See Also:
Serialized Form

Field Summary
static int BOTTOM
          This value indicates vertical orientation and that each column of components should be bottom-justified.
static int CENTER_VERTICAL
          This value indicates vertical orientation and that each column of components should be centered.
protected  boolean isHeightUniform
          Tracks component sizing of height.
protected  boolean isHorizontal
          Tracks orientation.
protected  boolean isWidthUniform
          Tracks component sizing of width.
static int TOP
          This value indicates vertical orientation and that each column of components should be top-justified.
 
Fields inherited from class java.awt.FlowLayout
CENTER, LEADING, LEFT, RIGHT, TRAILING
 
Constructor Summary
BetterFlowLayout()
          Constructs a new Flow Layout with a centered alignment and a default 5-unit horizontal and vertical gap.
BetterFlowLayout(int align)
          Constructs a new Flow Layout with the specified alignment and a default 5-unit horizontal and vertical gap.
BetterFlowLayout(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
protected  java.awt.Dimension getUniformDimension(java.awt.Container target)
          Returns a dimension representing the maximum preferred height and width of all the components in the container.
 boolean isHeightUniform()
          Determines whether all components will have the same height.
 boolean isWidthUniform()
          Determines whether all components will have the same width.
 void layoutContainer(java.awt.Container target)
          Lays out the container.
protected  void layoutContainerHorizontal(java.awt.Container target)
          Lays out the container.
protected  void layoutContainerVertical(java.awt.Container target)
          Lays out the container.
 java.awt.Dimension minimumLayoutSize(java.awt.Container target)
          Returns the minimum dimensions needed to layout the components contained in the specified target container.
 java.awt.Dimension preferredLayoutSize(java.awt.Container target)
          Returns the preferred dimensions for this layout given the components in the specified target container.
 java.awt.Dimension preferredLayoutSizeHorizontal(java.awt.Container target)
          Returns the preferred dimensions for this layout given the components in the specified target container.
 java.awt.Dimension preferredLayoutSizeVertical(java.awt.Container target)
          Returns the preferred dimensions for this layout given the components in the specified target container.
 void setAlignment(int align)
          Sets the alignment for this layout.
 void setHeightUniform(boolean isUniform)
          Sets whether all components should have the same height.
 void setWidthUniform(boolean isUniform)
          Sets whether all components should have the same width.
 java.lang.String toString()
          Returns a string representation of this BetterFlowLayout object and its values.
 
Methods inherited from class java.awt.FlowLayout
addLayoutComponent, getAlignment, getHgap, getVgap, removeLayoutComponent, setHgap, setVgap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TOP

public static final int TOP
This value indicates vertical orientation and that each column of components should be top-justified.

See Also:
Constant Field Values

CENTER_VERTICAL

public static final int CENTER_VERTICAL
This value indicates vertical orientation and that each column of components should be centered.

See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
This value indicates vertical orientation and that each column of components should be bottom-justified.

See Also:
Constant Field Values

isHorizontal

protected boolean isHorizontal
Tracks orientation.


isWidthUniform

protected boolean isWidthUniform
Tracks component sizing of width.


isHeightUniform

protected boolean isHeightUniform
Tracks component sizing of height.

Constructor Detail

BetterFlowLayout

public BetterFlowLayout()
Constructs a new Flow Layout with a centered alignment and a default 5-unit horizontal and vertical gap.


BetterFlowLayout

public BetterFlowLayout(int align)
Constructs a new Flow Layout with the specified alignment and a default 5-unit horizontal and vertical gap. The value of the alignment argument must be one of BetterFlowLayout.LEFT, BetterFlowLayout.RIGHT, or BetterFlowLayout.CENTER.

Parameters:
align - the alignment value

BetterFlowLayout

public BetterFlowLayout(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 BetterFlowLayout.LEFT, BetterFlowLayout.RIGHT, or BetterFlowLayout.CENTER.

Parameters:
align - the alignment value.
hgap - the horizontal gap between components.
vgap - the vertical gap between components.
Method Detail

setHeightUniform

public void setHeightUniform(boolean isUniform)
Sets whether all components should have the same height.

Parameters:
isUniform - the new value.
See Also:
isHeightUniform

setWidthUniform

public void setWidthUniform(boolean isUniform)
Sets whether all components should have the same width.

Parameters:
isUniform - the new value.
See Also:
isWidthUniform

isHeightUniform

public boolean isHeightUniform()
Determines whether all components will have the same height. The uniform height will be the maximum of the preferred heights of all the components in the container. This value defaults to false.

Returns:
whether components will have the same height.

isWidthUniform

public boolean isWidthUniform()
Determines whether all components will have the same width. The uniform height will be the maximum of the preferred widths of all the components in the container. This value defaults to false.

Returns:
whether components will have the same width.

setAlignment

public void setAlignment(int align)
Sets the alignment for this layout. Possible values for horizontal orientation are LEFT, RIGHT, and CENTER. Possible values for vertical orientation are TOP, BOTTOM, and CENTER_VERTICAL.

Overrides:
setAlignment in class java.awt.FlowLayout
Parameters:
align - the alignment value.
See Also:
FlowLayout.getAlignment()

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container target)
Returns the preferred dimensions for this layout given the components in the specified target container.

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
Overrides:
preferredLayoutSize in class java.awt.FlowLayout
Parameters:
target - the component which 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()

preferredLayoutSizeHorizontal

public java.awt.Dimension preferredLayoutSizeHorizontal(java.awt.Container target)
Returns the preferred dimensions for this layout given the components in the specified target container.

Parameters:
target - the component which 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()

preferredLayoutSizeVertical

public java.awt.Dimension preferredLayoutSizeVertical(java.awt.Container target)
Returns the preferred dimensions for this layout given the components in the specified target container.

Parameters:
target - the component which 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 java.awt.Dimension minimumLayoutSize(java.awt.Container target)
Returns the minimum dimensions needed to layout the components contained in the specified target container.

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
Overrides:
minimumLayoutSize in class java.awt.FlowLayout
Parameters:
target - the component which needs to be laid out
Returns:
the minimum dimensions to lay out the subcomponents of the specified container.
See Also:
preferredLayoutSize(java.awt.Container), Container, Container.doLayout()

layoutContainer

public void layoutContainer(java.awt.Container target)
Lays out the container. This method lets each component take its preferred size by reshaping the components in the target container in order to satisfy the constraints of this BetterFlowLayout object.

Specified by:
layoutContainer in interface java.awt.LayoutManager
Overrides:
layoutContainer in class java.awt.FlowLayout
Parameters:
target - the specified component being laid out.
See Also:
Container, Container.doLayout()

layoutContainerHorizontal

protected void layoutContainerHorizontal(java.awt.Container target)
Lays out the container. This method lets each component take its preferred size by reshaping the components in the target container in order to satisfy the constraints of this BetterFlowLayout object.

Parameters:
target - the specified component being laid out.
See Also:
Container, Container.doLayout()

layoutContainerVertical

protected void layoutContainerVertical(java.awt.Container target)
Lays out the container. This method lets each component take its preferred size by reshaping the components in the target container in order to satisfy the constraints of this BetterFlowLayout object.

Parameters:
target - the specified component being laid out.
See Also:
Container, Container.doLayout()

getUniformDimension

protected java.awt.Dimension getUniformDimension(java.awt.Container target)
Returns a dimension representing the maximum preferred height and width of all the components in the container.

Parameters:
target - the container to scan.
Returns:
a dimension containing the maximum values.

toString

public java.lang.String toString()
Returns a string representation of this BetterFlowLayout object and its values.

Overrides:
toString in class java.awt.FlowLayout
Returns:
a string representation of this layout.


Copyright © 2006 null. All Rights Reserved.