com.sas.visuals
Class BoxLayout

com.sas.visuals.BoxLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2, java.io.Serializable

public class BoxLayout
implements java.awt.LayoutManager2, java.io.Serializable

BoxLayout is a layoutManager that positions components in an arrangement similar to the java.awt.BorderLayout, but also allows for individual margins between the components. A component is positioned based on the orientation it is added with. It also allows for overlapping components and switching a components orientation without adding/removing the component.

Notes:


See Also:
Serialized Form

Field Summary
static int BOTTOM
          BOTTOM orientation value
static int LEFT
          LEFT orientation value
static int NONE
          NONE orientation value ( places component at the center of the container )
static int RIGHT
          RIGHT orientation value
static int TOP
          TOP orientation value
 
Constructor Summary
BoxLayout()
          Constructs a new BorderLayout with no margins between components.
BoxLayout(int topGap, int bottomGap, int rightGap, int leftGap)
          Constructs a BorderLayout with the specified margins between components.
 
Method Summary
 void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
          Adds the specified component to the layout, using the specified constraint object.
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Deprecated.  
 void changeOrientation(java.awt.Component comp, int newOrientation)
          Change the orientation of a component in this layout.
 int getBottomBorder()
          Get the gap between the bottom and center components.
 int getBottomHeight()
          Get the height to set the bottom component's height.
 float getLayoutAlignmentX(java.awt.Container parent)
          Returns the alignment along the x axis.
 float getLayoutAlignmentY(java.awt.Container parent)
          Returns the alignment along the y axis.
 int getLeftBorder()
          Get the gap between the left and center components.
 int getLeftWidth()
          Get the width to set the left component's width.
 int getRightBorder()
          Get the gap between the right and center components.
 int getRightWidth()
          Get the width to set the right component's width.
 int getTopBorder()
          Get the gap between the top and center components.
 int getTopHeight()
          Get the height to set the top component's height.
 void invalidateLayout(java.awt.Container target)
          Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
 void layoutContainer(java.awt.Container parent)
          Lays out the specified container.
 java.awt.Dimension maximumLayoutSize(java.awt.Container target)
          Returns the maximum dimensions for this layout given the components in the specified target container.
 java.awt.Dimension minimumLayoutSize(java.awt.Container target)
          Returns the minimum dimensions needed to layout 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)
          Removes the specified component from the layout.
 void setBottomBorder(int size)
          Set the gap between the bottom and center components.
 void setBottomHeight(int size)
          Set the height to set the bottom component's height.
 void setLeftBorder(int size)
          Set the gap between the left and center components.
 void setLeftWidth(int size)
          Set the width to set the left component's width.
 void setRightBorder(int size)
          Set the gap between the right and center components.
 void setRightWidth(int size)
          Set the width to set the right component's width.
 void setTopBorder(int size)
          Set the gap between the top and center components.
 void setTopHeight(int size)
          Set the height to set the top component's height.
 java.lang.String toString()
          Returns the String representation of this BorderLayout's values.
 

Field Detail

NONE

public static final int NONE
NONE orientation value ( places component at the center of the container )

See Also:
Constant Field Values

TOP

public static final int TOP
TOP orientation value

See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
BOTTOM orientation value

See Also:
Constant Field Values

LEFT

public static final int LEFT
LEFT orientation value

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
RIGHT orientation value

See Also:
Constant Field Values
Constructor Detail

BoxLayout

public BoxLayout()
Constructs a new BorderLayout with no margins between components.


BoxLayout

public BoxLayout(int topGap,
                 int bottomGap,
                 int rightGap,
                 int leftGap)
Constructs a BorderLayout with the specified margins between components.

Parameters:
topGap - the gap between the top and the center components
bottomGap - the gap between the bottom and the center components
rightGap - the gap between the right and the center components
leftGap - the gap between the left and the center components
Method Detail

getTopBorder

public int getTopBorder()
Get the gap between the top and center components.


setTopBorder

public void setTopBorder(int size)
Set the gap between the top and center components.


getBottomBorder

public int getBottomBorder()
Get the gap between the bottom and center components.


setBottomBorder

public void setBottomBorder(int size)
Set the gap between the bottom and center components.


getRightBorder

public int getRightBorder()
Get the gap between the right and center components.


setRightBorder

public void setRightBorder(int size)
Set the gap between the right and center components.


getLeftBorder

public int getLeftBorder()
Get the gap between the left and center components.


setLeftBorder

public void setLeftBorder(int size)
Set the gap between the left and center components.


getTopHeight

public int getTopHeight()
Get the height to set the top component's height. This is only used if the topHeight is greater than the preferred height of the top component.


setTopHeight

public void setTopHeight(int size)
Set the height to set the top component's height. This is only used if the topHeight is greater than the preferred height of the top component.


getBottomHeight

public int getBottomHeight()
Get the height to set the bottom component's height. This is only used if the bottomHeight is greater than the preferred height of the bottom component.


setBottomHeight

public void setBottomHeight(int size)
Set the height to set the bottom component's height. This is only used if the bottomHeight is greater than the preferred height of the bottom component.


getRightWidth

public int getRightWidth()
Get the width to set the right component's width. This is only used if the rightWidth is greater than the preferred width of the right component.


setRightWidth

public void setRightWidth(int size)
Set the width to set the right component's width. This is only used if the rightWidth is greater than the preferred width of the right component.


getLeftWidth

public int getLeftWidth()
Get the width to set the left component's width. This is only used if the leftWidth is greater than the preferred width of the left component.


setLeftWidth

public void setLeftWidth(int size)
Set the width to set the left component's width. This is only used if the leftWidth is greater than the preferred width of the left component.


changeOrientation

public void changeOrientation(java.awt.Component comp,
                              int newOrientation)
Change the orientation of a component in this layout. If another component is in the orientation already, switch the orientations of both of the components.

Parameters:
comp - the component to change the orientation of
newOrientation - the components new orientation.

addLayoutComponent

public void addLayoutComponent(java.awt.Component comp,
                               java.lang.Object constraints)
Adds the specified component to the layout, using the specified constraint object.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager2
Parameters:
comp - the component to be added
constraints - where/how the component is added to the layout.

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Deprecated. 

Replaced by addLayoutComponent(Component, Object).

Specified by:
addLayoutComponent in interface java.awt.LayoutManager

removeLayoutComponent

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

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

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container target)
Returns the minimum dimensions needed to layout the components contained in the specified target container.

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
Parameters:
target - the Container on which to do the layout
See Also:
Container, preferredLayoutSize(java.awt.Container)

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 component which needs to be laid out
See Also:
Container, minimumLayoutSize(java.awt.Container)

maximumLayoutSize

public java.awt.Dimension maximumLayoutSize(java.awt.Container target)
Returns the maximum dimensions for this layout given the components in the specified target container.

Specified by:
maximumLayoutSize in interface java.awt.LayoutManager2
Parameters:
target - the component which needs to be laid out
See Also:
Container, minimumLayoutSize(java.awt.Container), preferredLayoutSize(java.awt.Container)

getLayoutAlignmentX

public float getLayoutAlignmentX(java.awt.Container parent)
Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Specified by:
getLayoutAlignmentX in interface java.awt.LayoutManager2

getLayoutAlignmentY

public float getLayoutAlignmentY(java.awt.Container parent)
Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Specified by:
getLayoutAlignmentY in interface java.awt.LayoutManager2

invalidateLayout

public void invalidateLayout(java.awt.Container target)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.

Specified by:
invalidateLayout in interface java.awt.LayoutManager2

layoutContainer

public void layoutContainer(java.awt.Container parent)
Lays out the specified container. This method will actually reshape the components in the specified target container in order to satisfy the constraints of the BorderLayout object.

Specified by:
layoutContainer in interface java.awt.LayoutManager
Parameters:
target - the component being laid out
See Also:
Container

toString

public java.lang.String toString()
Returns the String representation of this BorderLayout's values.

Overrides:
toString in class java.lang.Object



Copyright © 2009 SAS Institute Inc. All Rights Reserved.