becker.gui
Class RowLayout

java.lang.Object
  extended by becker.gui.RowLayout
All Implemented Interfaces:
LayoutManager

public class RowLayout
extends Object
implements LayoutManager

A RowLayout manages the layout of a container's components. The components are laid out in a row according to their preferred sizes. If the components will not fit into the container they are all scaled by the same amount in both the horizontal and vertical dimensions so they will fit.

By default, all components will be laid out so their bottoms are aligned. A RowLayout may also be set to align the tops or centers of the components. Similarly, the row itself is centered horizontally by default but may be set to align at either the left or the right of the container.

Author:
Byron Weber Becker

Field Summary
static int ALIGN_BOTTOMS
          Vertically align the bottoms of the components.
static int ALIGN_CENTERS
          Vertically align the centers of the components.
static int ALIGN_TOPS
          Vertically align the tops of the components.
static int JUSTIFY_CENTER
          Position the components in the center of the container.
static int JUSTIFY_LEFT
          Position the components as far left as possible within the container.
static int JUSTIFY_RIGHT
          Position the components as far right as possible within the container.
 
Constructor Summary
RowLayout()
          Construct a new RowLayout layout manager which aligns component bottoms and center justifies the row.
RowLayout(int alignment, int justification)
          Construst a new RowLayout layout manager.
 
Method Summary
 void addLayoutComponent(String name, Component comp)
          Adds the specified component with the specified name to the layout.
 int getHgap()
          Get the horizontal gap between components.
 void layoutContainer(Container parent)
          Lays out the container in the specified panel.
 Dimension minimumLayoutSize(Container parent)
          Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.
 Dimension preferredLayoutSize(Container parent)
          Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.
 void removeLayoutComponent(Component comp)
          Removes the specified component from the layout.
 void setHgap(int gap)
          Set the horizontal gap between components.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALIGN_BOTTOMS

public static final int ALIGN_BOTTOMS
Vertically align the bottoms of the components.

See Also:
Constant Field Values

ALIGN_CENTERS

public static final int ALIGN_CENTERS
Vertically align the centers of the components.

See Also:
Constant Field Values

ALIGN_TOPS

public static final int ALIGN_TOPS
Vertically align the tops of the components.

See Also:
Constant Field Values

JUSTIFY_LEFT

public static final int JUSTIFY_LEFT
Position the components as far left as possible within the container.

See Also:
Constant Field Values

JUSTIFY_CENTER

public static final int JUSTIFY_CENTER
Position the components in the center of the container.

See Also:
Constant Field Values

JUSTIFY_RIGHT

public static final int JUSTIFY_RIGHT
Position the components as far right as possible within the container.

See Also:
Constant Field Values
Constructor Detail

RowLayout

public RowLayout()
Construct a new RowLayout layout manager which aligns component bottoms and center justifies the row.


RowLayout

public RowLayout(int alignment,
                 int justification)
Construst a new RowLayout layout manager.

Parameters:
alignment - How the components are aligned vertically. One of {ALIGN_BOTTOMS, ALIGN_CENTERS, ALIGN_TOPS}.
justification - How the row of components is justified horizontally. One of {JUSTIFY_LEFT, JUSTIFY_CENTER, JUSTIFY_RIGHT}.
Method Detail

addLayoutComponent

public void addLayoutComponent(String name,
                               Component comp)
Adds the specified component with the specified name to the layout.

Specified by:
addLayoutComponent in interface LayoutManager
Parameters:
name - the component name
comp - the component to be added

removeLayoutComponent

public void removeLayoutComponent(Component comp)
Removes the specified component from the layout.

Specified by:
removeLayoutComponent in interface LayoutManager
Parameters:
comp - the component to be removed

preferredLayoutSize

public Dimension preferredLayoutSize(Container parent)
Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.

Specified by:
preferredLayoutSize in interface LayoutManager
Parameters:
parent - the component to be laid out
See Also:
minimumLayoutSize(java.awt.Container)

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)
Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.

Specified by:
minimumLayoutSize in interface LayoutManager
Parameters:
parent - the component to be laid out
See Also:
preferredLayoutSize(java.awt.Container)

layoutContainer

public void layoutContainer(Container parent)
Lays out the container in the specified panel.

Specified by:
layoutContainer in interface LayoutManager
Parameters:
parent - the component which needs to be laid out

setHgap

public void setHgap(int gap)
Set the horizontal gap between components.

Parameters:
gap - The gap between components, in pixels.

getHgap

public int getHgap()
Get the horizontal gap between components.

Returns:
The gap between components, in pixels.