javax.swing

Class SpringLayout.Constraints

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
Constraints()
Creates a new Constraints object.
Constraints(Spring x, Spring y)
Creates a new Constraints object.
Constraints(Spring x, Spring y, Spring width, Spring height)
Creates a new Constraints object.
Constraints(Component component)
Create a new Constraints object which tracks the indicated component.
Method Summary
voiddropCalcResult()
SpringgetConstraint(String edgeName)
Returns the constraint for the edge with the edgeName.
SpringgetEast()
Returns the constraint for the right edge of the component.
SpringgetHeight()
Returns the constraint for the height of the component.
SpringgetSouth()
Returns the constraint for the lower edge of the component.
SpringgetWidth()
Returns the constraint for the width of the component.
SpringgetX()
Returns the constraint for the left edge of the component.
SpringgetY()
Returns the constraint for the upper edge of the component.
voidsetConstraint(String edgeName, Spring s)
Sets a constraint for the specified edge.
voidsetEast(Spring s)
Sets the EAST-constraint.
voidsetHeight(Spring s)
Sets the height-constraint.
voidsetSouth(Spring s)
Sets the SOUTH-constraint.
voidsetWidth(Spring s)
Sets the width-constraint.
voidsetX(Spring s)
Sets the WEST-constraint.
voidsetY(Spring s)
Sets the NORTH-constraint.

Constructor Detail

Constraints

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

Constraints

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

Constraints

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

Constraints

public 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 {@link Spring#width(Component)} and {@link Spring#height(Component)}, respectively.

Parameters: component the component to track

Since: 1.5

Method Detail

dropCalcResult

public void dropCalcResult()

getConstraint

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

Parameters: edgeName the name of the edge.

Returns: the constraint for the specified edge.

getEast

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

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

getHeight

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

Returns: the height constraint.

getSouth

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

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

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).

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 {@link #EAST}, {@link #WEST}, {@link #NORTH} or {@link #SOUTH}. s the constraint to be set.

setEast

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

Parameters: s the constraint to be set.

setHeight

public void setHeight(Spring s)
Sets the height-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.

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.