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
Simple Springs and Structs 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);
 
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.


Variable Index

 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 DEFAULT_SPRINGS_MASK
The default values for those JComponents that do not have explict values set.
 o HEIGHT_CAN_CHANGE
Indicates that the height of the widget will grow and shrink as the parent component changes size.
 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 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 SPRINGS_KEY
This is the key used in the object properties list to store the springs value.
 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 WIDTH_CAN_CHANGE
Indicates that the width of the widget will grow and shrink as the parent component changes size.

Constructor Index

 o SpringLayout()

Method Index

 o addLayoutComponent(Component, Object)
If constraints is a valid spring object (as returned from constraintForSprings()) then these constraints will be set on the comp.
 o addLayoutComponent(String, Component)
 o constraintForSprings(int)
Returns an object 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(JComponent)
Returns the current spring settings for this container.
 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 preferredLayoutSize(Container)
Returns the parent's size.
 o removeLayoutComponent(Component)
 o resetOriginalBounds(JComponent)
The first time the parent is asked to layout, it's bounds and the bounds of it's immediate children are cached.
 o setSprings(JComponent, int)
Sets the springs values for this container.

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 DEFAULT_SPRINGS_MASK
 public static final int DEFAULT_SPRINGS_MASK
The default values for those JComponents that do not have explict values set. Defined to be: RIGHT_MARGIN_CAN_CHANGE | BOTTOM_MARGIN_CAN_CHANGE

 o SPRINGS_KEY
 public 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.

Constructors

 o SpringLayout
 public SpringLayout()

Methods

 o setSprings
 public void setSprings(JComponent 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(JComponent container)
Returns the current spring settings for this container. If no values have been set returns DEFAULT_SPRINGS_MASK.

 o constraintForSprings
 public Object constraintForSprings(int spring)
Returns an object 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 addLayoutComponent(Component, Object) 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(JComponent 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 constraintForSprings()) then these constraints will be set on the comp. Normally you will use setSprings() to sccomplish this. If constraints is invalid, this method will not set any spring information on the comp.

 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)

All Packages  Class Hierarchy  This Package  Previous  Next  Index