All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.SpringLayout

java.lang.Object
   |
   +----com.sun.java.swing.SpringLayout

public class SpringLayout
extends Object
implements LayoutManager2, Serializable
Simple Springs and Struts LayoutManager. The _CAN_CHANGE values can be or-ed together to specify all the springs for a component. For example:
       layout.setSprings(widget, SpringLayout.RIGHT_MARGIN_CAN_CHANGE
                                   | SpringLayout.TOP_MARGIN_CAN_CHANGE));
 or 
       parent.add(child, SpringLayout.RIGHT_TOP_SPRINGS);
 
Space will be evenly distributed among all springs along a single axis. i.e. If you have set the springs such that RIGHT_MARGIN_CAN_CHANGE | LEFT_MARGIN_CAN_CHANGE and the parent grows by 10 pixels in the x dimension, the left and right margins of the child will each grow by 5 pixels.

This layout manager does not determine default sizes for components. It simply allocates changes in space to the components as appropriate. To properly utilize this LayoutManager, you should specify the bounds of the Components prior to placing them in the view hierarchy. When the parent's bounds change, the children will have their bounds changed accoordingly.

The current implementation manages the springs as a set of integer values. You may pass an Integer object as a constraint to the add(component, constraint) method of Container. For example:

      parent.add(child, new Integer(SpringLayout.RIGHT_MARGIN_CAN_CHANGE
                                       | SpringLayout.TOP_MARGIN_CAN_CHANGE));
 
Using the createSpring() is the preferred manner of getting a properly configured constraint object.


Variable Index

 o BOTTOM_LEFT_SPRINGS
Convience constraint object.
 o BOTTOM_MARGIN_CAN_CHANGE
Indicates that the space to the bottom of widget will grow and shrink as the parent component changes size.
 o BOTTOM_RIGHT_SPRINGS
Convience constraint object.
 o BOTTOM_SPRING
Convience constraint object.
 o CENTER_HORIZ_SPRINGS
Convience constraint object.
 o CENTER_VERT_SPRINGS
Convience constraint object.
 o componentAttributes
 o HEIGHT_CAN_CHANGE
Indicates that the height of the widget will grow and shrink as the parent component changes size.
 o HEIGHT_SPRING
Convience constraint object.
 o HEIGHT_WIDTH_SPRING
Convience constraint object.
 o HW_SPRINGS_MASK
 o LEFT_MARGIN_CAN_CHANGE
Indicates that the space to the left of widget will grow and shrink as the parent component changes size.
 o LEFT_SPRING
Convience constraint object.
 o noticeBoundsChanged
 o ORIGINAL_BOUNDS_KEY
This is the key used in the object properties list to store the orginal bounds of the component.
 o RIGHT_MARGIN_CAN_CHANGE
Indicates that the space to the right of widget will grow and shrink as the parent component changes size.
 o RIGHT_SPRING
Convience constraint object.
 o SPRINGS_KEY
This is the key used in the object properties list to store the springs value.
 o TOP_LEFT_SPRINGS
Convience constraint object.
 o TOP_MARGIN_CAN_CHANGE
Indicates that the space to the top of widget will grow and shrink as the parent component changes size.
 o TOP_RIGHT_SPRINGS
Convience constraint object.
 o TOP_SPRING
Convience constraint object.
 o VALIDITY_MASK
 o WIDTH_CAN_CHANGE
Indicates that the width of the widget will grow and shrink as the parent component changes size.
 o WIDTH_SPRING
Convience constraint object.

Constructor Index

 o SpringLayout()

Method Index

 o addLayoutComponent(Component, Object)
If constraints is a valid spring object (as returned from createSpring()) then these constraints will be set on the comp.
 o addLayoutComponent(String, Component)
 o createSpring(int)
Returns an Integer used for storing springs in data structures needing objects.
 o getLayoutAlignmentX(Container)
Returns the target's alignment x.
 o getLayoutAlignmentY(Container)
Returns the target's alignment y.
 o getSprings(Component)
Returns the current spring settings for this container.
 o horizontalSpringCount(int)
 o invalidateLayout(Container)
 o isValidSpring(int)
Returns false if spring is not a valid combination of springs.
 o layoutContainer(Container)
Performs the actual layout of the component based on their spring settings.
 o maximumLayoutSize(Container)
Returns the target's maximum size.
 o minimumLayoutSize(Container)
Returns the parent's minimum size.
 o originalBoundsFor(Component)
 o preferredLayoutSize(Container)
Returns the parent's size.
 o removeLayoutComponent(Component)
 o resetOriginalBounds(Container)
The first time the parent is asked to layout, it's bounds and the bounds of it's immediate children are cached.
 o setSprings(Component, int)
Sets the springs values for this container.
 o storeOriginalBoundsFor(Component, Rectangle)
 o verticalSpringCount(int)

Variables

 o RIGHT_MARGIN_CAN_CHANGE
 public static final int RIGHT_MARGIN_CAN_CHANGE
Indicates that the space to the right of widget will grow and shrink as the parent component changes size.

 o LEFT_MARGIN_CAN_CHANGE
 public static final int LEFT_MARGIN_CAN_CHANGE
Indicates that the space to the left of widget will grow and shrink as the parent component changes size.

 o TOP_MARGIN_CAN_CHANGE
 public static final int TOP_MARGIN_CAN_CHANGE
Indicates that the space to the top of widget will grow and shrink as the parent component changes size.

 o BOTTOM_MARGIN_CAN_CHANGE
 public static final int BOTTOM_MARGIN_CAN_CHANGE
Indicates that the space to the bottom of widget will grow and shrink as the parent component changes size.

 o WIDTH_CAN_CHANGE
 public static final int WIDTH_CAN_CHANGE
Indicates that the width of the widget will grow and shrink as the parent component changes size.

 o HEIGHT_CAN_CHANGE
 public static final int HEIGHT_CAN_CHANGE
Indicates that the height of the widget will grow and shrink as the parent component changes size.

 o HW_SPRINGS_MASK
 protected static final int HW_SPRINGS_MASK
 o VALIDITY_MASK
 protected static final int VALIDITY_MASK
 o RIGHT_SPRING
 public static final Integer RIGHT_SPRING
Convience constraint object. Equivalent to RIGHT_MARGIN_CAN_CHANGE.

 o LEFT_SPRING
 public static final Integer LEFT_SPRING
Convience constraint object. Equivalent to LEFT_MARGIN_CAN_CHANGE.

 o TOP_SPRING
 public static final Integer TOP_SPRING
Convience constraint object. Equivalent to TOP_MARGIN_CAN_CHANGE.

 o BOTTOM_SPRING
 public static final Integer BOTTOM_SPRING
Convience constraint object. Equivalent to BOTTOM_MARGIN_CAN_CHANGE.

 o WIDTH_SPRING
 public static final Integer WIDTH_SPRING
Convience constraint object. Equivalent to WIDTH_CAN_CHANGE.

 o HEIGHT_SPRING
 public static final Integer HEIGHT_SPRING
Convience constraint object. Equivalent to HEIGHT_CAN_CHANGE.

 o HEIGHT_WIDTH_SPRING
 public static final Integer HEIGHT_WIDTH_SPRING
Convience constraint object. Equivalent to HEIGHT_CAN_CHANGE | WIDTH_CAN_CHANGE.

 o CENTER_HORIZ_SPRINGS
 public static final Integer CENTER_HORIZ_SPRINGS
Convience constraint object. Equivalent to LEFT_MARGIN_CAN_CHANGE | RIGHT_MARGIN_CAN_CHANGE.

 o CENTER_VERT_SPRINGS
 public static final Integer CENTER_VERT_SPRINGS
Convience constraint object. Equivalent to TOP_MARGIN_CAN_CHANGE | BOTTOM_MARGIN_CAN_CHANGE.

 o BOTTOM_LEFT_SPRINGS
 public static final Integer BOTTOM_LEFT_SPRINGS
Convience constraint object. Equivalent to LEFT_MARGIN_CAN_CHANGE | BOTTOM_MARGIN_CAN_CHANGE.

 o BOTTOM_RIGHT_SPRINGS
 public static final Integer BOTTOM_RIGHT_SPRINGS
Convience constraint object. Equivalent to RIGHT_MARGIN_CAN_CHANGE | BOTTOM_MARGIN_CAN_CHANGE.

 o TOP_RIGHT_SPRINGS
 public static final Integer TOP_RIGHT_SPRINGS
Convience constraint object. Equivalent to RIGHT_MARGIN_CAN_CHANGE | TOP_MARGIN_CAN_CHANGE.

 o TOP_LEFT_SPRINGS
 public static final Integer TOP_LEFT_SPRINGS
Convience constraint object. Equivalent to LEFT_MARGIN_CAN_CHANGE | TOP_MARGIN_CAN_CHANGE.

 o SPRINGS_KEY
 protected static final String SPRINGS_KEY
This is the key used in the object properties list to store the springs value.

 o ORIGINAL_BOUNDS_KEY
 protected static final String ORIGINAL_BOUNDS_KEY
This is the key used in the object properties list to store the orginal bounds of the component.

 o noticeBoundsChanged
 protected boolean noticeBoundsChanged
 o componentAttributes
 protected Hashtable componentAttributes

Constructors

 o SpringLayout
 public SpringLayout()

Methods

 o setSprings
 public void setSprings(Component container,
                        int springs)
Sets the springs values for this container. springs must be a valid combination of the constants defined, or this method will throw an IllegalArgumentException.

 o getSprings
 public int getSprings(Component container)
Returns the current spring settings for this container. If no values have been set returns BOTTOM_RIGHT_SPRINGS.intValue().

 o createSpring
 public static Integer createSpring(int spring)
Returns an Integer used for storing springs in data structures needing objects. Current implementation returns a shared instance for common values. This object can be passed into the add(component, constraint) method as a constraint.

 o isValidSpring
 public boolean isValidSpring(int spring)
Returns false if spring is not a valid combination of springs.

 o resetOriginalBounds
 public void resetOriginalBounds(Container parent)
The first time the parent is asked to layout, it's bounds and the bounds of it's immediate children are cached. Changes in size are calculated from this original bounds. Calling this method causes the cache to be updated to the current bounds of the parent and it's immediate children. This can be useful, if you have manually adjusted the bounds of a view after it's already had layout called on it, and you want all further calculations to use the updated values. You normally won't need to call this method.

 o addLayoutComponent
 public void addLayoutComponent(String name,
                                Component comp)
 o removeLayoutComponent
 public void removeLayoutComponent(Component comp)
 o preferredLayoutSize
 public Dimension preferredLayoutSize(Container parent)
Returns the parent's size.

 o minimumLayoutSize
 public Dimension minimumLayoutSize(Container parent)
Returns the parent's minimum size.

 o layoutContainer
 public void layoutContainer(Container parent)
Performs the actual layout of the component based on their spring settings.

 o addLayoutComponent
 public void addLayoutComponent(Component comp,
                                Object constraints)
If constraints is a valid spring object (as returned from createSpring()) then these constraints will be set on the comp. Normally you will use setSprings() to accomplish this. If constraints is invalid, this method throw an IllegalArgumentException.

 o maximumLayoutSize
 public Dimension maximumLayoutSize(Container target)
Returns the target's maximum size.

 o getLayoutAlignmentX
 public float getLayoutAlignmentX(Container target)
Returns the target's alignment x.

 o getLayoutAlignmentY
 public float getLayoutAlignmentY(Container target)
Returns the target's alignment y.

 o invalidateLayout
 public void invalidateLayout(Container target)
 o verticalSpringCount
 protected int verticalSpringCount(int springs)
 o horizontalSpringCount
 protected int horizontalSpringCount(int springs)
 o originalBoundsFor
 protected Rectangle originalBoundsFor(Component view)
 o storeOriginalBoundsFor
 protected void storeOriginalBoundsFor(Component view,
                                       Rectangle bounds)

All Packages  Class Hierarchy  This Package  Previous  Next  Index