javax.swing
Class SpringLayout.Constraints

java.lang.Object
  extended by javax.swing.SpringLayout.Constraints
Enclosing class:
SpringLayout

public static class SpringLayout.Constraints
extends Object

The constraints that define the relationships between components. Each Constraints object can hold 4 Springs: one for each edge of the component. Additionally it can hold Springs for the components width and the components height. Since the height and width constraints are dependend on the other constraints, a component can be over-constraint. In this case (like when all of NORTH, SOUTH and HEIGHT are constraint), the values are adjusted, so that the mathematics still hold true.


Constructor Summary
SpringLayout.Constraints()
          Creates a new Constraints object.
SpringLayout.Constraints(Component component)
          Create a new Constraints object which tracks the indicated component.
SpringLayout.Constraints(Spring x, Spring y)
          Creates a new Constraints object.
SpringLayout.Constraints(Spring x, Spring y, Spring width, Spring height)
          Creates a new Constraints object.
 
Method Summary
 void dropCalcResult()
           
 Spring getConstraint(String edgeName)
          Returns the constraint for the edge with the edgeName.
 Spring getEast()
          Returns the constraint for the right edge of the component.
 Spring getHeight()
          Returns the constraint for the height of the component.
 Spring getSouth()
          Returns the constraint for the lower edge of the component.
 Spring getWidth()
          Returns the constraint for the width of the component.
 Spring getX()
          Returns the constraint for the left edge of the component.
 Spring getY()
          Returns the constraint for the upper edge of the component.
 void setConstraint(String edgeName, Spring s)
          Sets a constraint for the specified edge.
 void setEast(Spring s)
          Sets the EAST-constraint.
 void setHeight(Spring s)
          Sets the height-constraint.
 void setSouth(Spring s)
          Sets the SOUTH-constraint.
 void setWidth(Spring s)
          Sets the width-constraint.
 void setX(Spring s)
          Sets the WEST-constraint.
 void setY(Spring s)
          Sets the NORTH-constraint.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpringLayout.Constraints

public SpringLayout.Constraints()
Creates a new Constraints object. There is no constraint set.


SpringLayout.Constraints

public SpringLayout.Constraints(Spring x,
                                Spring y)
Creates a new Constraints object.

Parameters:
x - the constraint for the left edge of the component.
y - the constraint for the upper edge of the component.

SpringLayout.Constraints

public SpringLayout.Constraints(Spring x,
                                Spring y,
                                Spring width,
                                Spring height)
Creates a new Constraints object.

Parameters:
x - the constraint for the left edge of the component.
y - the constraint for the upper edge of the component.
width - the constraint for the width of the component.
height - the constraint for the height of the component.

SpringLayout.Constraints

public SpringLayout.Constraints(Component component)
Create a new Constraints object which tracks the indicated component. The x and y positions for this Constraints object are constant Springs created with the component's location at the time this constructor is called. The width and height of this Constraints are Springs created using Spring.width(Component) and Spring.height(Component), respectively.

Parameters:
component - the component to track
Since:
1.5
Method Detail

getConstraint

public Spring getConstraint(String edgeName)
Returns the constraint for the edge with the edgeName. This is expected to be one of SpringLayout.EAST, SpringLayout.WEST, SpringLayout.NORTH or SpringLayout.SOUTH.

Parameters:
edgeName - the name of the edge.
Returns:
the constraint for the specified edge.

getHeight

public Spring getHeight()
Returns the constraint for the height of the component.

Returns:
the height constraint.

getWidth

public Spring getWidth()
Returns the constraint for the width of the component.

Returns:
the width constraint.

getX

public Spring getX()
Returns the constraint for the left edge of the component.

Returns:
the left-edge constraint (== WEST).

getY

public Spring getY()
Returns the constraint for the upper edge of the component.

Returns:
the upper-edge constraint (== NORTH).

getSouth

public Spring getSouth()
Returns the constraint for the lower edge of the component.

Returns:
the lower-edge constraint (== SOUTH).

getEast

public Spring getEast()
Returns the constraint for the right edge of the component.

Returns:
the right-edge constraint (== EAST).

setConstraint

public void setConstraint(String edgeName,
                          Spring s)
Sets a constraint for the specified edge. If this leads to an over-constrained situation, the constraints get adjusted, so that the mathematics still hold true.

Parameters:
edgeName - the name of the edge, one of SpringLayout.EAST, SpringLayout.WEST, SpringLayout.NORTH or SpringLayout.SOUTH.
s - the constraint to be set.

setHeight

public void setHeight(Spring s)
Sets the height-constraint.

Parameters:
s - the constraint to be set.

setWidth

public void setWidth(Spring s)
Sets the width-constraint.

Parameters:
s - the constraint to be set.

setX

public void setX(Spring s)
Sets the WEST-constraint.

Parameters:
s - the constraint to be set.

setY

public void setY(Spring s)
Sets the NORTH-constraint.

Parameters:
s - the constraint to be set.

setSouth

public void setSouth(Spring s)
Sets the SOUTH-constraint.

Parameters:
s - the constraint to be set.

setEast

public void setEast(Spring s)
Sets the EAST-constraint.

Parameters:
s - the constraint to be set.

dropCalcResult

public void dropCalcResult()