javax.swing

Class BoxLayout

public class BoxLayout extends Object implements LayoutManager2, Serializable

A layout that stacks the children of a container in a Box, either horizontally or vertically.
Field Summary
static intLINE_AXIS
Specifies that components are laid out in the direction of a line of text.
static intPAGE_AXIS
Sepcifies that components are laid out in the direction of the line flow.
static intX_AXIS
Specifies that components are laid out left to right.
static intY_AXIS
Specifies that components are laid out top to bottom.
Constructor Summary
BoxLayout(Container container, int way)
Constructs a BoxLayout object.
Method Summary
voidaddLayoutComponent(String name, Component component)
Adds a component to the layout.
voidaddLayoutComponent(Component child, Object constraints)
Adds a component to the layout.
floatgetLayoutAlignmentX(Container parent)
Returns the alignment along the X axis for the container.
floatgetLayoutAlignmentY(Container parent)
Returns the alignment along the Y axis for the container.
voidinvalidateLayout(Container parent)
Invalidates the layout.
voidlayoutContainer(Container parent)
Lays out the specified container using this layout.
DimensionmaximumLayoutSize(Container parent)
Returns the maximum size of the layout gived the components in the given container.
DimensionminimumLayoutSize(Container parent)
Returns the minimum size of the layout.
DimensionpreferredLayoutSize(Container parent)
Returns the preferred size of the layout.
voidremoveLayoutComponent(Component component)
Removes a component from the layout.

Field Detail

LINE_AXIS

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

PAGE_AXIS

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

X_AXIS

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

Y_AXIS

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

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.

Parameters: name The name of the component to add. component the component to add to the layout.

addLayoutComponent

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

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.

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.

Parameters: parent The container that needs to be laid out.

Returns: The alignment.

invalidateLayout

public void invalidateLayout(Container parent)
Invalidates the layout.

Parameters: parent The container that needs to be laid out.

layoutContainer

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

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.

Parameters: parent The container that needs to be laid out.

Returns: The dimension of the layout.

minimumLayoutSize

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

Parameters: parent The container that needs to be laid out.

Returns: The dimension of the layout.

preferredLayoutSize

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

Parameters: parent The container that needs to be laid out.

Returns: The dimension of the layout.

removeLayoutComponent

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

Parameters: component The component to remove from the layout.