javax.swing
Class BoxLayout

java.lang.Object
  extended by javax.swing.BoxLayout
All Implemented Interfaces:
LayoutManager, LayoutManager2, Serializable
Direct Known Subclasses:
DefaultMenuLayout

public class BoxLayout
extends Object
implements LayoutManager2, Serializable

A layout that stacks the children of a container in a Box, either horizontally or vertically.

See Also:
Serialized Form

Field Summary
static int LINE_AXIS
          Specifies that components are laid out in the direction of a line of text.
static int PAGE_AXIS
          Sepcifies that components are laid out in the direction of the line flow.
static int X_AXIS
          Specifies that components are laid out left to right.
static int Y_AXIS
          Specifies that components are laid out top to bottom.
 
Constructor Summary
BoxLayout(Container container, int way)
          Constructs a BoxLayout object.
 
Method Summary
 void addLayoutComponent(Component child, Object constraints)
          Adds a component to the layout.
 void addLayoutComponent(String name, Component component)
          Adds a component to the layout.
 float getLayoutAlignmentX(Container parent)
          Returns the alignment along the X axis for the container.
 float getLayoutAlignmentY(Container parent)
          Returns the alignment along the Y axis for the container.
 void invalidateLayout(Container parent)
          Invalidates the layout.
 void layoutContainer(Container parent)
          Lays out the specified container using this layout.
 Dimension maximumLayoutSize(Container parent)
          Returns the maximum size of the layout gived the components in the given container.
 Dimension minimumLayoutSize(Container parent)
          Returns the minimum size of the layout.
 Dimension preferredLayoutSize(Container parent)
          Returns the preferred size of the layout.
 void removeLayoutComponent(Component component)
          Removes a component from the layout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

X_AXIS

public static final int X_AXIS
Specifies that components are laid out left to right.

See Also:
Constant Field Values

Y_AXIS

public static final int Y_AXIS
Specifies that components are laid out top to bottom.

See Also:
Constant Field Values

LINE_AXIS

public static final int LINE_AXIS
Specifies that components are laid out in the direction of a line of text.

See Also:
Constant Field Values

PAGE_AXIS

public static final int PAGE_AXIS
Sepcifies that components are laid out in the direction of the line flow.

See Also:
Constant Field Values
Constructor Detail

BoxLayout

public BoxLayout(Container container,
                 int way)
Constructs a BoxLayout object.

Parameters:
container - The container that needs to be laid out.
way - The orientation of the components.
Throws:
AWTError - If way has an invalid value.
Method Detail

addLayoutComponent

public void addLayoutComponent(String name,
                               Component component)
Adds a component to the layout. Not used in BoxLayout.

Specified by:
addLayoutComponent in interface LayoutManager
Parameters:
name - The name of the component to add.
component - the component to add to the layout.

removeLayoutComponent

public void removeLayoutComponent(Component component)
Removes a component from the layout. Not used in BoxLayout.

Specified by:
removeLayoutComponent in interface LayoutManager
Parameters:
component - The component to remove from the layout.

preferredLayoutSize

public Dimension preferredLayoutSize(Container parent)
Returns the preferred size of the layout.

Specified by:
preferredLayoutSize in interface LayoutManager
Parameters:
parent - The container that needs to be laid out.
Returns:
The dimension of the layout.
See Also:
LayoutManager.minimumLayoutSize(Container)

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)
Returns the minimum size of the layout.

Specified by:
minimumLayoutSize in interface LayoutManager
Parameters:
parent - The container that needs to be laid out.
Returns:
The dimension of the layout.
See Also:
LayoutManager.preferredLayoutSize(Container)

layoutContainer

public void layoutContainer(Container parent)
Lays out the specified container using this layout.

Specified by:
layoutContainer in interface LayoutManager
Parameters:
parent - The container that needs to be laid out.

addLayoutComponent

public void addLayoutComponent(Component child,
                               Object constraints)
Adds a component to the layout. Not used in BoxLayout

Specified by:
addLayoutComponent in interface LayoutManager2
Parameters:
child - The component to add to the layout.
constraints - The constraints for the component in the layout.

getLayoutAlignmentX

public float getLayoutAlignmentX(Container parent)
Returns the alignment along the X axis for the container.

Specified by:
getLayoutAlignmentX in interface LayoutManager2
Parameters:
parent - The container that needs to be laid out.
Returns:
The alignment.

getLayoutAlignmentY

public float getLayoutAlignmentY(Container parent)
Returns the alignment along the Y axis for the container.

Specified by:
getLayoutAlignmentY in interface LayoutManager2
Parameters:
parent - The container that needs to be laid out.
Returns:
The alignment.

invalidateLayout

public void invalidateLayout(Container parent)
Invalidates the layout.

Specified by:
invalidateLayout in interface LayoutManager2
Parameters:
parent - The container that needs to be laid out.

maximumLayoutSize

public Dimension maximumLayoutSize(Container parent)
Returns the maximum size of the layout gived the components in the given container.

Specified by:
maximumLayoutSize in interface LayoutManager2
Parameters:
parent - The container that needs to be laid out.
Returns:
The dimension of the layout.
See Also:
Component.getMaximumSize()