com.zfqjava.swing
Class BoxLayout2

java.lang.Object
  |
  +--com.zfqjava.swing.BoxLayout2
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2, java.io.Serializable

public class BoxLayout2
extends java.lang.Object
implements java.awt.LayoutManager2, java.io.Serializable

BoxLayout2 provides another BoxLayout and is helpful for layout button area.
It adds following features:


Note:
Since BoxLayout2 is compitable with BoxLayout at API level, use it just replace BoxLayout with BoxLayout2.

See Also:
Box, ComponentOrientation, JComponent.getAlignmentX(), JComponent.getAlignmentY(), Serialized Form

Field Summary
static int LINE_AXIS
          Specifies that components should be laid out in the direction of a line of text as determined by the target container's ComponentOrientation property.
static int PAGE_AXIS
          Specifies that components should be laid out in the direction that lines flow across a page as determined by the target container's ComponentOrientation property.
static int X_AXIS
          Specifies that components should be laid out left to right.
static int Y_AXIS
          Specifies that components should be laid out top to bottom.
 
Constructor Summary
BoxLayout2(java.awt.Container target, int axis)
          Creates a layout manager that will lay out components along the given axis.
BoxLayout2(java.awt.Container target, int axis, boolean equalsWidth, boolean equalsHeight)
          Creates a layout manager that will lay out components along the given axis.
 
Method Summary
 void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
          Not used by this class.
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Not used by this class.
protected  boolean canGroup(java.awt.Component c)
          Judge the component can be group.
 float getLayoutAlignmentX(java.awt.Container target)
          Returns the alignment along the X axis for the container.
 float getLayoutAlignmentY(java.awt.Container target)
          Returns the alignment along the Y axis for the container.
 void invalidateLayout(java.awt.Container target)
          Indicates that a child has changed its layout related information, and thus any cached calculations should be flushed.
 void layoutContainer(java.awt.Container target)
          Called by the AWT when the specified container needs to be laid out.
 java.awt.Dimension maximumLayoutSize(java.awt.Container target)
          Returns the maximum dimensions the target container can use to lay out the components it contains.
 java.awt.Dimension minimumLayoutSize(java.awt.Container target)
          Returns the minimum dimensions needed to lay out 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.
 void removeLayoutComponent(java.awt.Component comp)
          Not used by this class.
 
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 should be laid out left to right.

Y_AXIS

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

LINE_AXIS

public static final int LINE_AXIS
Specifies that components should be laid out in the direction of a line of text as determined by the target container's ComponentOrientation property.

PAGE_AXIS

public static final int PAGE_AXIS
Specifies that components should be laid out in the direction that lines flow across a page as determined by the target container's ComponentOrientation property.
Constructor Detail

BoxLayout2

public BoxLayout2(java.awt.Container target,
                  int axis)
Creates a layout manager that will lay out components along the given axis.
Parameters:
target - the container that needs to be laid out
axis - the axis to lay out components along. Can be one of: BoxLayout.X_AXIS, BoxLayout.Y_AXIS, BoxLayout.LINE_AXIS or BoxLayout.PAGE_AXIS
Throws:
AWTError - if the value of axis is invalid

BoxLayout2

public BoxLayout2(java.awt.Container target,
                  int axis,
                  boolean equalsWidth,
                  boolean equalsHeight)
Creates a layout manager that will lay out components along the given axis.
Parameters:
target - the container that needs to be laid out
axis - the axis to lay out components along. Can be one of: BoxLayout.X_AXIS, BoxLayout.Y_AXIS, BoxLayout.LINE_AXIS or BoxLayout.PAGE_AXIS
equalsWidth - specify all component has the equals width
equalsHeight - specify all component has the equals height
Throws:
AWTError - if the value of axis is invalid
Since:
JWizardPane 1.2
Method Detail

invalidateLayout

public void invalidateLayout(java.awt.Container target)
Indicates that a child has changed its layout related information, and thus any cached calculations should be flushed.

This method is called by AWT when the invalidate method is called on the Container. Since the invalidate method may be called asynchronously to the event thread, this method may be called asynchronously.

Specified by:
invalidateLayout in interface java.awt.LayoutManager2
Parameters:
target - the affected container
Throws:
AWTError - if the target isn't the container specified to the BoxLayout constructor

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Not used by this class.
Specified by:
addLayoutComponent in interface java.awt.LayoutManager
Parameters:
name - the name of the component
comp - the component

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Not used by this class.
Specified by:
removeLayoutComponent in interface java.awt.LayoutManager
Parameters:
comp - the component

addLayoutComponent

public void addLayoutComponent(java.awt.Component comp,
                               java.lang.Object constraints)
Not used by this class.
Specified by:
addLayoutComponent in interface java.awt.LayoutManager2
Parameters:
comp - the component
constraints - constraints

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
Parameters:
target - the container that needs to be laid out
Returns:
the dimensions >= 0 && <= Integer.MAX_VALUE
Throws:
AWTError - if the target isn't the container specified to the BoxLayout constructor
See Also:
Container, minimumLayoutSize(java.awt.Container), maximumLayoutSize(java.awt.Container)

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container target)
Returns the minimum dimensions needed to lay out the components contained in the specified target container.
Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
Parameters:
target - the container that needs to be laid out
Returns:
the dimensions >= 0 && <= Integer.MAX_VALUE
Throws:
AWTError - if the target isn't the container specified to the BoxLayout constructor
See Also:
preferredLayoutSize(java.awt.Container), maximumLayoutSize(java.awt.Container)

maximumLayoutSize

public java.awt.Dimension maximumLayoutSize(java.awt.Container target)
Returns the maximum dimensions the target container can use to lay out the components it contains.
Specified by:
maximumLayoutSize in interface java.awt.LayoutManager2
Parameters:
target - the container that needs to be laid out
Returns:
the dimenions >= 0 && <= Integer.MAX_VALUE
Throws:
AWTError - if the target isn't the container specified to the BoxLayout constructor
See Also:
preferredLayoutSize(java.awt.Container), minimumLayoutSize(java.awt.Container)

getLayoutAlignmentX

public float getLayoutAlignmentX(java.awt.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.
Specified by:
getLayoutAlignmentX in interface java.awt.LayoutManager2
Parameters:
target - the container
Returns:
the alignment >= 0.0f && <= 1.0f
Throws:
AWTError - if the target isn't the container specified to the BoxLayout constructor

getLayoutAlignmentY

public float getLayoutAlignmentY(java.awt.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.
Specified by:
getLayoutAlignmentY in interface java.awt.LayoutManager2
Parameters:
target - the container
Returns:
the alignment >= 0.0f && <= 1.0f
Throws:
AWTError - if the target isn't the container specified to the BoxLayout constructor

layoutContainer

public void layoutContainer(java.awt.Container target)
Called by the AWT when the specified container needs to be laid out.
Specified by:
layoutContainer in interface java.awt.LayoutManager
Parameters:
target - the container to lay out
Throws:
AWTError - if the target isn't the container specified to the BoxLayout constructor

canGroup

protected boolean canGroup(java.awt.Component c)
Judge the component can be group.


Copyright © 2001-2003 Extreme Component, Inc. All rights reserved.