All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.swing.BoxLayout
java.lang.Object
|
+----java.awt.swing.BoxLayout
- public class BoxLayout
- extends Object
- implements LayoutManager2, Serializable
A layout manager that places each of its managed components
from left to right
or from top to bottom.
When you create a BoxLayout,
you specify whether its major axis is the X axis
(which means left to right placement)
or Y axis (top to bottom placement).
Components are arranged from left to right (or top to bottom),
in the same order as they were added to the container.
[A figure should go here.]
Instead of using BoxLayout directly,
many programs use the Box class.
The Box class provides a lightweight container
that uses a BoxLayout.
Box also provides handy methods
to help you use BoxLayout well.
BoxLayout attempts to arrange components
at their preferred widths (for left to right layout)
or heights (for top to bottom layout).
For a left to right layout,
if not all the components are the same height,
BoxLayout attempts to make all the components
as high as the highest component.
If that's not possible for a particular component,
then BoxLayout aligns that component vertically,
according to the component's Y alignment.
By default, a component has an Y alignment of 0.5,
which means that the vertical center of the component
should have the same Y coordinate as
the vertical centers of other components with 0.5 Y alignment.
[A figure and description should go here.]
Similarly, for a vertical layout,
BoxLayout attempts to make all components in the column
as wide as the widest component;
if that fails, it aligns them horizontally
according to their X alignments.
- See Also:
- Box, getAlignmentX, getAlignmentY
X_AXIS- Specifies that components should be laid out left to right.
Y_AXIS- Specifies that components should be laid out top to buttom.
BoxLayout(Container, int)
- Creates a layout manager that will lay out components either
left to right or
top to bottom,
as specified in the
axis
parameter.
addLayoutComponent(Component, Object)
- Not used by this class.
addLayoutComponent(String, Component)
- Not used by this class.
getLayoutAlignmentX(Container)
- Returns the alignment along the X axis for the container.
getLayoutAlignmentY(Container)
- Returns the alignment along the Y axis for the container.
invalidateLayout(Container)
- Indicates that a child has changed its layout related information,
and thus any cached calculations should be flushed.
layoutContainer(Container)
- Called by the AWT when the specified container
needs to be laid out.
maximumLayoutSize(Container)
- Returns the minimum dimensions needed to lay out the components
contained in the specified target container.
minimumLayoutSize(Container)
- Returns the minimum dimensions needed to layout the components
contained in the specified target container.
preferredLayoutSize(Container)
- Returns the preferred dimensions for this layout, given the components
in the specified target container.
removeLayoutComponent(Component)
- Not used by this class.
X_AXIS
public static final int X_AXIS
- Specifies that components should be laid out left to right.
Y_AXIS
public static final int Y_AXIS
- Specifies that components should be laid out top to buttom.
BoxLayout
public BoxLayout(Container target,
int axis)
- Creates a layout manager that will lay out components either
left to right or
top to bottom,
as specified in the
axis
parameter.
- Parameters:
- target - the container that needs to be laid out
- axis - the axis to lay out components along.
For left-to-right layout,
specify
BoxLayout.X_AXIS
;
for top-to-bottom layout,
specify BoxLayout.Y_AXIS
- Throws:
AWTError
- if the value of
axis
is invalid
invalidateLayout
public void invalidateLayout(Container target)
- Indicates that a child has changed its layout related information,
and thus any cached calculations should be flushed.
- Parameters:
- target - the affected container
- Throws:
AWTError
- if the target isn't the container specified to the
BoxLayout constructor
addLayoutComponent
public void addLayoutComponent(String name,
Component comp)
- Not used by this class.
removeLayoutComponent
public void removeLayoutComponent(Component comp)
- Not used by this class.
addLayoutComponent
public void addLayoutComponent(Component comp,
Object constraints)
- Not used by this class.
preferredLayoutSize
public Dimension preferredLayoutSize(Container target)
- Returns the preferred dimensions for this layout, given the components
in the specified target container.
- Parameters:
- target - the container that needs to be laid out
- Throws:
AWTError
- if the target isn't the container specified to the
BoxLayout constructor
- See Also:
- Container, minimumLayoutSize, maximumLayoutSize
minimumLayoutSize
public Dimension minimumLayoutSize(Container target)
- Returns the minimum dimensions needed to layout the components
contained in the specified target container.
- Parameters:
- target - the container that needs to be laid out
- Throws:
AWTError
- if the target isn't the container specified to the
BoxLayout constructor
- See Also:
- preferredLayoutSize, maximumLayoutSize
maximumLayoutSize
public Dimension maximumLayoutSize(Container target)
- Returns the minimum dimensions needed to lay out the components
contained in the specified target container.
- Parameters:
- target - the container that needs to be laid out
- Throws:
AWTError
- if the target isn't the container specified to the
BoxLayout constructor
- See Also:
- preferredLayoutSize, minimumLayoutSize
getLayoutAlignmentX
public float getLayoutAlignmentX(Container target)
- Returns the alignment along the X axis for the container.
If the box is horizontal, the default
alignment will be returned. Otherwise, the alignment needed
to place the children along the X axis will be returned.
- Parameters:
- target - the container that needs to be laid out
- Throws:
AWTError
- if the target isn't the container specified to the
BoxLayout constructor
getLayoutAlignmentY
public float getLayoutAlignmentY(Container target)
- Returns the alignment along the Y axis for the container.
If the box is vertical, the default
alignment will be returned. Otherwise, the alignment needed
to place the children along the Y axis will be returned.
- Parameters:
- target - the container that needs to be laid out
- Throws:
AWTError
- if the target isn't the container specified to the
BoxLayout constructor
layoutContainer
public void layoutContainer(Container target)
- Called by the AWT when the specified container
needs to be laid out.
- Parameters:
- target - the container to lay out
- Throws:
AWTError
- if the target isn't the container specified to the
BoxLayout constructor
All Packages Class Hierarchy This Package Previous Next Index
Submit a bug or feature