javax.swing
Class SpringLayout

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.swing.SpringLayout
All Implemented Interfaces:
LayoutManager sample code for java.awt.LayoutManager definition code for java.awt.LayoutManager , LayoutManager2 sample code for java.awt.LayoutManager2 definition code for java.awt.LayoutManager2

public class SpringLayout
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements LayoutManager2 sample code for java.awt.LayoutManager2 definition code for java.awt.LayoutManager2

A SpringLayout lays out the children of its associated container according to a set of constraints. See How to Use SpringLayout in The Java Tutorial for examples of using SpringLayout.

Each constraint, represented by a Spring object, controls the vertical or horizontal distance between two component edges. The edges can belong to any child of the container, or to the container itself. For example, the allowable width of a component can be expressed using a constraint that controls the distance between the west (left) and east (right) edges of the component. The allowable y coordinates for a component can be expressed by constraining the distance between the north (top) edge of the component and the north edge of its container.

Every child of a SpringLayout-controlled container, as well as the container itself, has exactly one set of constraints associated with it. These constraints are represented by a SpringLayout.Constraints object. By default, SpringLayout creates constraints that make their associated component have the minimum, preferred, and maximum sizes returned by the component's Component.getMinimumSize() sample code for java.awt.Component.getMinimumSize() definition code for java.awt.Component.getMinimumSize() , Component.getPreferredSize() sample code for java.awt.Component.getPreferredSize() definition code for java.awt.Component.getPreferredSize() , and Component.getMaximumSize() sample code for java.awt.Component.getMaximumSize() definition code for java.awt.Component.getMaximumSize() methods. The x and y positions are initially not constrained, so that until you constrain them the Component will be positioned at 0,0 relative to the Insets of the parent Container.

You can change a component's constraints in several ways. You can use one of the putConstraint sample code for javax.swing.SpringLayout.putConstraint(java.lang.String, java.awt.Component, int, java.lang.String, java.awt.Component) definition code for javax.swing.SpringLayout.putConstraint(java.lang.String, java.awt.Component, int, java.lang.String, java.awt.Component) methods to establish a spring linking the edges of two components within the same container. Or you can get the appropriate SpringLayout.Constraints object using getConstraints sample code for javax.swing.SpringLayout.getConstraints(java.awt.Component) definition code for javax.swing.SpringLayout.getConstraints(java.awt.Component) and then modify one or more of its springs. Or you can get the spring for a particular edge of a component using getConstraint sample code for javax.swing.SpringLayout.getConstraint(java.lang.String, java.awt.Component) definition code for javax.swing.SpringLayout.getConstraint(java.lang.String, java.awt.Component) , and modify it. You can also associate your own SpringLayout.Constraints object with a component by specifying the constraints object when you add the component to its container (using Container.add(Component, Object) sample code for java.awt.Container.add(java.awt.Component, java.lang.Object) definition code for java.awt.Container.add(java.awt.Component, java.lang.Object) ).

The Spring object representing each constraint has a minimum, preferred, maximum, and current value. The current value of the spring is somewhere between the minimum and maximum values, according to the formula given in the Spring.sum(javax.swing.Spring, javax.swing.Spring) sample code for javax.swing.Spring.sum(javax.swing.Spring, javax.swing.Spring) definition code for javax.swing.Spring.sum(javax.swing.Spring, javax.swing.Spring) method description. When the minimum, preferred, and maximum values are the same, the current value is always equal to them; this inflexible spring is called a strut. You can create struts using the factory method Spring.constant(int) sample code for javax.swing.Spring.constant(int) definition code for javax.swing.Spring.constant(int) . The Spring class also provides factory methods for creating other kinds of springs, including springs that depend on other springs.

In a SpringLayout, the position of each edge is dependent on the position of just one other edge. If a constraint is subsequently added to create a new binding for an edge, the previous binding is discarded and the edge remains dependent on a single edge. Springs should only be attached between edges of the container and its immediate children; the behavior of the SpringLayout when presented with constraints linking the edges of components from different containers (either internal or external) is undefined.

SpringLayout vs. Other Layout Managers


Note: Unlike many layout managers, SpringLayout doesn't automatically set the location of the components it manages. If you hand-code a GUI that uses SpringLayout, remember to initialize component locations by constraining the west/east and north/south locations.

Depending on the constraints you use, you may also need to set the size of the container explicitly.


Despite the simplicity of SpringLayout, it can emulate the behavior of most other layout managers. For some features, such as the line breaking provided by FlowLayout, you'll need to create a special-purpose subclass of the Spring class.

SpringLayout also provides a way to solve many of the difficult layout problems that cannot be solved by nesting combinations of Boxes. That said, SpringLayout honors the LayoutManager2 contract correctly and so can be nested with other layout managers -- a technique that can be preferable to creating the constraints implied by the other layout managers.

The asymptotic complexity of the layout operation of a SpringLayout is linear in the number of constraints (and/or components).

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder sample code for java.beans.XMLEncoder definition code for java.beans.XMLEncoder .

Since:
1.4
See Also:
Spring sample code for javax.swing.Spring definition code for javax.swing.Spring , SpringLayout.Constraints sample code for javax.swing.SpringLayout.Constraints definition code for javax.swing.SpringLayout.Constraints

Nested Class Summary
static class SpringLayout.Constraints sample code for javax.swing.SpringLayout.Constraints definition code for javax.swing.SpringLayout.Constraints
          A Constraints object holds the constraints that govern the way a component's size and position change in a container controlled by a SpringLayout.
 
Field Summary
static String sample code for java.lang.String definition code for java.lang.String EAST sample code for javax.swing.SpringLayout.EAST definition code for javax.swing.SpringLayout.EAST
          Specifies the right edge of a component's bounding rectangle.
static String sample code for java.lang.String definition code for java.lang.String NORTH sample code for javax.swing.SpringLayout.NORTH definition code for javax.swing.SpringLayout.NORTH
          Specifies the top edge of a component's bounding rectangle.
static String sample code for java.lang.String definition code for java.lang.String SOUTH sample code for javax.swing.SpringLayout.SOUTH definition code for javax.swing.SpringLayout.SOUTH
          Specifies the bottom edge of a component's bounding rectangle.
static String sample code for java.lang.String definition code for java.lang.String WEST sample code for javax.swing.SpringLayout.WEST definition code for javax.swing.SpringLayout.WEST
          Specifies the left edge of a component's bounding rectangle.
 
Constructor Summary
SpringLayout sample code for javax.swing.SpringLayout.SpringLayout() definition code for javax.swing.SpringLayout.SpringLayout() ()
          Constructs a new SpringLayout.
 
Method Summary
 void addLayoutComponent sample code for javax.swing.SpringLayout.addLayoutComponent(java.awt.Component, java.lang.Object) definition code for javax.swing.SpringLayout.addLayoutComponent(java.awt.Component, java.lang.Object) (Component sample code for java.awt.Component definition code for java.awt.Component  component, Object sample code for java.lang.Object definition code for java.lang.Object  constraints)
          If constraints is an instance of SpringLayout.Constraints, associates the constraints with the specified component.
 void addLayoutComponent sample code for javax.swing.SpringLayout.addLayoutComponent(java.lang.String, java.awt.Component) definition code for javax.swing.SpringLayout.addLayoutComponent(java.lang.String, java.awt.Component) (String sample code for java.lang.String definition code for java.lang.String  name, Component sample code for java.awt.Component definition code for java.awt.Component  c)
          Has no effect, since this layout manager does not use a per-component string.
 Spring sample code for javax.swing.Spring definition code for javax.swing.Spring getConstraint sample code for javax.swing.SpringLayout.getConstraint(java.lang.String, java.awt.Component) definition code for javax.swing.SpringLayout.getConstraint(java.lang.String, java.awt.Component) (String sample code for java.lang.String definition code for java.lang.String  edgeName, Component sample code for java.awt.Component definition code for java.awt.Component  c)
          Returns the spring controlling the distance between the specified edge of the component and the top or left edge of its parent.
 SpringLayout.Constraints sample code for javax.swing.SpringLayout.Constraints definition code for javax.swing.SpringLayout.Constraints getConstraints sample code for javax.swing.SpringLayout.getConstraints(java.awt.Component) definition code for javax.swing.SpringLayout.getConstraints(java.awt.Component) (Component sample code for java.awt.Component definition code for java.awt.Component  c)
          Returns the constraints for the specified component.
 float getLayoutAlignmentX sample code for javax.swing.SpringLayout.getLayoutAlignmentX(java.awt.Container) definition code for javax.swing.SpringLayout.getLayoutAlignmentX(java.awt.Container) (Container sample code for java.awt.Container definition code for java.awt.Container  p)
          Returns 0.5f (centered).
 float getLayoutAlignmentY sample code for javax.swing.SpringLayout.getLayoutAlignmentY(java.awt.Container) definition code for javax.swing.SpringLayout.getLayoutAlignmentY(java.awt.Container) (Container sample code for java.awt.Container definition code for java.awt.Container  p)
          Returns 0.5f (centered).
 void invalidateLayout sample code for javax.swing.SpringLayout.invalidateLayout(java.awt.Container) definition code for javax.swing.SpringLayout.invalidateLayout(java.awt.Container) (Container sample code for java.awt.Container definition code for java.awt.Container  p)
          Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
 void layoutContainer sample code for javax.swing.SpringLayout.layoutContainer(java.awt.Container) definition code for javax.swing.SpringLayout.layoutContainer(java.awt.Container) (Container sample code for java.awt.Container definition code for java.awt.Container  parent)
          Lays out the specified container.
 Dimension sample code for java.awt.Dimension definition code for java.awt.Dimension maximumLayoutSize sample code for javax.swing.SpringLayout.maximumLayoutSize(java.awt.Container) definition code for javax.swing.SpringLayout.maximumLayoutSize(java.awt.Container) (Container sample code for java.awt.Container definition code for java.awt.Container  parent)
          Calculates the maximum size dimensions for the specified container, given the components it contains.
 Dimension sample code for java.awt.Dimension definition code for java.awt.Dimension minimumLayoutSize sample code for javax.swing.SpringLayout.minimumLayoutSize(java.awt.Container) definition code for javax.swing.SpringLayout.minimumLayoutSize(java.awt.Container) (Container sample code for java.awt.Container definition code for java.awt.Container  parent)
          Calculates the minimum size dimensions for the specified container, given the components it contains.
 Dimension sample code for java.awt.Dimension definition code for java.awt.Dimension preferredLayoutSize sample code for javax.swing.SpringLayout.preferredLayoutSize(java.awt.Container) definition code for javax.swing.SpringLayout.preferredLayoutSize(java.awt.Container) (Container sample code for java.awt.Container definition code for java.awt.Container  parent)
          Calculates the preferred size dimensions for the specified container, given the components it contains.
 void putConstraint sample code for javax.swing.SpringLayout.putConstraint(java.lang.String, java.awt.Component, int, java.lang.String, java.awt.Component) definition code for javax.swing.SpringLayout.putConstraint(java.lang.String, java.awt.Component, int, java.lang.String, java.awt.Component) (String sample code for java.lang.String definition code for java.lang.String  e1, Component sample code for java.awt.Component definition code for java.awt.Component  c1, int pad, String sample code for java.lang.String definition code for java.lang.String  e2, Component sample code for java.awt.Component definition code for java.awt.Component  c2)
          Links edge e1 of component c1 to edge e2 of component c2, with a fixed distance between the edges.
 void putConstraint sample code for javax.swing.SpringLayout.putConstraint(java.lang.String, java.awt.Component, javax.swing.Spring, java.lang.String, java.awt.Component) definition code for javax.swing.SpringLayout.putConstraint(java.lang.String, java.awt.Component, javax.swing.Spring, java.lang.String, java.awt.Component) (String sample code for java.lang.String definition code for java.lang.String  e1, Component sample code for java.awt.Component definition code for java.awt.Component  c1, Spring sample code for javax.swing.Spring definition code for javax.swing.Spring  s, String sample code for java.lang.String definition code for java.lang.String  e2, Component sample code for java.awt.Component definition code for java.awt.Component  c2)
          Links edge e1 of component c1 to edge e2 of component c2.
 void removeLayoutComponent sample code for javax.swing.SpringLayout.removeLayoutComponent(java.awt.Component) definition code for javax.swing.SpringLayout.removeLayoutComponent(java.awt.Component) (Component sample code for java.awt.Component definition code for java.awt.Component  c)
          Removes the constraints associated with the specified component.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

NORTH sample code for javax.swing.SpringLayout.NORTH

public static final String sample code for java.lang.String definition code for java.lang.String  NORTH
Specifies the top edge of a component's bounding rectangle.

See Also:
Constant Field Values

SOUTH sample code for javax.swing.SpringLayout.SOUTH

public static final String sample code for java.lang.String definition code for java.lang.String  SOUTH
Specifies the bottom edge of a component's bounding rectangle.

See Also:
Constant Field Values

EAST sample code for javax.swing.SpringLayout.EAST

public static final String sample code for java.lang.String definition code for java.lang.String  EAST
Specifies the right edge of a component's bounding rectangle.

See Also:
Constant Field Values

WEST sample code for javax.swing.SpringLayout.WEST

public static final String sample code for java.lang.String definition code for java.lang.String  WEST
Specifies the left edge of a component's bounding rectangle.

See Also:
Constant Field Values
Constructor Detail

SpringLayout sample code for javax.swing.SpringLayout() definition code for javax.swing.SpringLayout()

public SpringLayout()
Constructs a new SpringLayout.

Method Detail

addLayoutComponent sample code for javax.swing.SpringLayout.addLayoutComponent(java.lang.String, java.awt.Component) definition code for javax.swing.SpringLayout.addLayoutComponent(java.lang.String, java.awt.Component)

public void addLayoutComponent(String sample code for java.lang.String definition code for java.lang.String  name,
                               Component sample code for java.awt.Component definition code for java.awt.Component  c)
Has no effect, since this layout manager does not use a per-component string.

Specified by:
addLayoutComponent sample code for java.awt.LayoutManager.addLayoutComponent(java.lang.String, java.awt.Component) definition code for java.awt.LayoutManager.addLayoutComponent(java.lang.String, java.awt.Component) in interface LayoutManager sample code for java.awt.LayoutManager definition code for java.awt.LayoutManager
Parameters:
name - the string to be associated with the component
c - the component to be added

removeLayoutComponent sample code for javax.swing.SpringLayout.removeLayoutComponent(java.awt.Component) definition code for javax.swing.SpringLayout.removeLayoutComponent(java.awt.Component)

public void removeLayoutComponent(Component sample code for java.awt.Component definition code for java.awt.Component  c)
Removes the constraints associated with the specified component.

Specified by:
removeLayoutComponent sample code for java.awt.LayoutManager.removeLayoutComponent(java.awt.Component) definition code for java.awt.LayoutManager.removeLayoutComponent(java.awt.Component) in interface LayoutManager sample code for java.awt.LayoutManager definition code for java.awt.LayoutManager
Parameters:
c - the component being removed from the container

minimumLayoutSize sample code for javax.swing.SpringLayout.minimumLayoutSize(java.awt.Container) definition code for javax.swing.SpringLayout.minimumLayoutSize(java.awt.Container)

public Dimension sample code for java.awt.Dimension definition code for java.awt.Dimension  minimumLayoutSize(Container sample code for java.awt.Container definition code for java.awt.Container  parent)
Description copied from interface: LayoutManager sample code for java.awt.LayoutManager.minimumLayoutSize(java.awt.Container) definition code for java.awt.LayoutManager.minimumLayoutSize(java.awt.Container)
Calculates the minimum size dimensions for the specified container, given the components it contains.

Specified by:
minimumLayoutSize sample code for java.awt.LayoutManager.minimumLayoutSize(java.awt.Container) definition code for java.awt.LayoutManager.minimumLayoutSize(java.awt.Container) in interface LayoutManager sample code for java.awt.LayoutManager definition code for java.awt.LayoutManager
Parameters:
parent - the component to be laid out
See Also:
LayoutManager.preferredLayoutSize(java.awt.Container) sample code for java.awt.LayoutManager.preferredLayoutSize(java.awt.Container) definition code for java.awt.LayoutManager.preferredLayoutSize(java.awt.Container)

preferredLayoutSize sample code for javax.swing.SpringLayout.preferredLayoutSize(java.awt.Container) definition code for javax.swing.SpringLayout.preferredLayoutSize(java.awt.Container)

public Dimension sample code for java.awt.Dimension definition code for java.awt.Dimension  preferredLayoutSize(Container sample code for java.awt.Container definition code for java.awt.Container  parent)
Description copied from interface: LayoutManager sample code for java.awt.LayoutManager.preferredLayoutSize(java.awt.Container) definition code for java.awt.LayoutManager.preferredLayoutSize(java.awt.Container)
Calculates the preferred size dimensions for the specified container, given the components it contains.

Specified by:
preferredLayoutSize sample code for java.awt.LayoutManager.preferredLayoutSize(java.awt.Container) definition code for java.awt.LayoutManager.preferredLayoutSize(java.awt.Container) in interface LayoutManager sample code for java.awt.LayoutManager definition code for java.awt.LayoutManager
Parameters:
parent - the container to be laid out
See Also:
LayoutManager.minimumLayoutSize(java.awt.Container) sample code for java.awt.LayoutManager.minimumLayoutSize(java.awt.Container) definition code for java.awt.LayoutManager.minimumLayoutSize(java.awt.Container)

maximumLayoutSize sample code for javax.swing.SpringLayout.maximumLayoutSize(java.awt.Container) definition code for javax.swing.SpringLayout.maximumLayoutSize(java.awt.Container)

public Dimension sample code for java.awt.Dimension definition code for java.awt.Dimension  maximumLayoutSize(Container sample code for java.awt.Container definition code for java.awt.Container  parent)
Description copied from interface: LayoutManager2 sample code for java.awt.LayoutManager2.maximumLayoutSize(java.awt.Container) definition code for java.awt.LayoutManager2.maximumLayoutSize(java.awt.Container)
Calculates the maximum size dimensions for the specified container, given the components it contains.

Specified by:
maximumLayoutSize sample code for java.awt.LayoutManager2.maximumLayoutSize(java.awt.Container) definition code for java.awt.LayoutManager2.maximumLayoutSize(java.awt.Container) in interface LayoutManager2 sample code for java.awt.LayoutManager2 definition code for java.awt.LayoutManager2
See Also:
Component.getMaximumSize() sample code for java.awt.Component.getMaximumSize() definition code for java.awt.Component.getMaximumSize() , LayoutManager sample code for java.awt.LayoutManager definition code for java.awt.LayoutManager

addLayoutComponent sample code for javax.swing.SpringLayout.addLayoutComponent(java.awt.Component, java.lang.Object) definition code for javax.swing.SpringLayout.addLayoutComponent(java.awt.Component, java.lang.Object)

public void addLayoutComponent(Component sample code for java.awt.Component definition code for java.awt.Component  component,
                               Object sample code for java.lang.Object definition code for java.lang.Object  constraints)
If constraints is an instance of SpringLayout.Constraints, associates the constraints with the specified component.

Specified by:
addLayoutComponent sample code for java.awt.LayoutManager2.addLayoutComponent(java.awt.Component, java.lang.Object) definition code for java.awt.LayoutManager2.addLayoutComponent(java.awt.Component, java.lang.Object) in interface LayoutManager2 sample code for java.awt.LayoutManager2 definition code for java.awt.LayoutManager2
Parameters:
component - the component being added
constraints - the component's constraints
See Also:
SpringLayout.Constraints sample code for javax.swing.SpringLayout.Constraints definition code for javax.swing.SpringLayout.Constraints

getLayoutAlignmentX sample code for javax.swing.SpringLayout.getLayoutAlignmentX(java.awt.Container) definition code for javax.swing.SpringLayout.getLayoutAlignmentX(java.awt.Container)

public float getLayoutAlignmentX(Container sample code for java.awt.Container definition code for java.awt.Container  p)
Returns 0.5f (centered).

Specified by:
getLayoutAlignmentX sample code for java.awt.LayoutManager2.getLayoutAlignmentX(java.awt.Container) definition code for java.awt.LayoutManager2.getLayoutAlignmentX(java.awt.Container) in interface LayoutManager2 sample code for java.awt.LayoutManager2 definition code for java.awt.LayoutManager2

getLayoutAlignmentY sample code for javax.swing.SpringLayout.getLayoutAlignmentY(java.awt.Container) definition code for javax.swing.SpringLayout.getLayoutAlignmentY(java.awt.Container)

public float getLayoutAlignmentY(Container sample code for java.awt.Container definition code for java.awt.Container  p)
Returns 0.5f (centered).

Specified by:
getLayoutAlignmentY sample code for java.awt.LayoutManager2.getLayoutAlignmentY(java.awt.Container) definition code for java.awt.LayoutManager2.getLayoutAlignmentY(java.awt.Container) in interface LayoutManager2 sample code for java.awt.LayoutManager2 definition code for java.awt.LayoutManager2

invalidateLayout sample code for javax.swing.SpringLayout.invalidateLayout(java.awt.Container) definition code for javax.swing.SpringLayout.invalidateLayout(java.awt.Container)

public void invalidateLayout(Container sample code for java.awt.Container definition code for java.awt.Container  p)
Description copied from interface: LayoutManager2 sample code for java.awt.LayoutManager2.invalidateLayout(java.awt.Container) definition code for java.awt.LayoutManager2.invalidateLayout(java.awt.Container)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.

Specified by:
invalidateLayout sample code for java.awt.LayoutManager2.invalidateLayout(java.awt.Container) definition code for java.awt.LayoutManager2.invalidateLayout(java.awt.Container) in interface LayoutManager2 sample code for java.awt.LayoutManager2 definition code for java.awt.LayoutManager2

putConstraint sample code for javax.swing.SpringLayout.putConstraint(java.lang.String, java.awt.Component, int, java.lang.String, java.awt.Component) definition code for javax.swing.SpringLayout.putConstraint(java.lang.String, java.awt.Component, int, java.lang.String, java.awt.Component)

public void putConstraint(String sample code for java.lang.String definition code for java.lang.String  e1,
                          Component sample code for java.awt.Component definition code for java.awt.Component  c1,
                          int pad,
                          String sample code for java.lang.String definition code for java.lang.String  e2,
                          Component sample code for java.awt.Component definition code for java.awt.Component  c2)
Links edge e1 of component c1 to edge e2 of component c2, with a fixed distance between the edges. This constraint will cause the assignment
     value(e1, c1) = value(e2, c2) + pad
to take place during all subsequent layout operations.

Parameters:
e1 - the edge of the dependent
c1 - the component of the dependent
pad - the fixed distance between dependent and anchor
e2 - the edge of the anchor
c2 - the component of the anchor
See Also:
putConstraint(String, Component, Spring, String, Component) sample code for javax.swing.SpringLayout.putConstraint(java.lang.String, java.awt.Component, javax.swing.Spring, java.lang.String, java.awt.Component) definition code for javax.swing.SpringLayout.putConstraint(java.lang.String, java.awt.Component, javax.swing.Spring, java.lang.String, java.awt.Component)

putConstraint sample code for javax.swing.SpringLayout.putConstraint(java.lang.String, java.awt.Component, javax.swing.Spring, java.lang.String, java.awt.Component) definition code for javax.swing.SpringLayout.putConstraint(java.lang.String, java.awt.Component, javax.swing.Spring, java.lang.String, java.awt.Component)

public void putConstraint(String sample code for java.lang.String definition code for java.lang.String  e1,
                          Component sample code for java.awt.Component definition code for java.awt.Component  c1,
                          Spring sample code for javax.swing.Spring definition code for javax.swing.Spring  s,
                          String sample code for java.lang.String definition code for java.lang.String  e2,
                          Component sample code for java.awt.Component definition code for java.awt.Component  c2)
Links edge e1 of component c1 to edge e2 of component c2. As edge (e2, c2) changes value, edge (e1, c1) will be calculated by taking the (spring) sum of (e2, c2) and s. Each edge must have one of the following values: SpringLayout.NORTH, SpringLayout.SOUTH, SpringLayout.EAST, SpringLayout.WEST.

Parameters:
e1 - the edge of the dependent
c1 - the component of the dependent
s - the spring linking dependent and anchor
e2 - the edge of the anchor
c2 - the component of the anchor
See Also:
putConstraint(String, Component, int, String, Component) sample code for javax.swing.SpringLayout.putConstraint(java.lang.String, java.awt.Component, int, java.lang.String, java.awt.Component) definition code for javax.swing.SpringLayout.putConstraint(java.lang.String, java.awt.Component, int, java.lang.String, java.awt.Component) , NORTH sample code for javax.swing.SpringLayout.NORTH definition code for javax.swing.SpringLayout.NORTH , SOUTH sample code for javax.swing.SpringLayout.SOUTH definition code for javax.swing.SpringLayout.SOUTH , EAST sample code for javax.swing.SpringLayout.EAST definition code for javax.swing.SpringLayout.EAST , WEST sample code for javax.swing.SpringLayout.WEST definition code for javax.swing.SpringLayout.WEST

getConstraints sample code for javax.swing.SpringLayout.getConstraints(java.awt.Component) definition code for javax.swing.SpringLayout.getConstraints(java.awt.Component)

public SpringLayout.Constraints sample code for javax.swing.SpringLayout.Constraints definition code for javax.swing.SpringLayout.Constraints  getConstraints(Component sample code for java.awt.Component definition code for java.awt.Component  c)
Returns the constraints for the specified component. Note that, unlike the GridBagLayout getConstraints method, this method does not clone constraints. If no constraints have been associated with this component, this method returns a default constraints object positioned at 0,0 relative to the parent's Insets and its width/height constrained to the minimum, maximum, and preferred sizes of the component. The size characteristics are not frozen at the time this method is called; instead this method returns a constraints object whose characteristics track the characteristics of the component as they change.

Parameters:
c - the component whose constraints will be returned
Returns:
the constraints for the specified component

getConstraint sample code for javax.swing.SpringLayout.getConstraint(java.lang.String, java.awt.Component) definition code for javax.swing.SpringLayout.getConstraint(java.lang.String, java.awt.Component)

public Spring sample code for javax.swing.Spring definition code for javax.swing.Spring  getConstraint(String sample code for java.lang.String definition code for java.lang.String  edgeName,
                            Component sample code for java.awt.Component definition code for java.awt.Component  c)
Returns the spring controlling the distance between the specified edge of the component and the top or left edge of its parent. This method, instead of returning the current binding for the edge, returns a proxy that tracks the characteristics of the edge even if the edge is subsequently rebound. Proxies are intended to be used in builder envonments where it is useful to allow the user to define the constraints for a layout in any order. Proxies do, however, provide the means to create cyclic dependencies amongst the constraints of a layout. Such cycles are detected internally by SpringLayout so that the layout operation always terminates.

Parameters:
edgeName - must be SpringLayout.NORTH, SpringLayout.SOUTH, SpringLayout.EAST, or SpringLayout.WEST
c - the component whose edge spring is desired
Returns:
a proxy for the spring controlling the distance between the specified edge and the top or left edge of its parent
See Also:
NORTH sample code for javax.swing.SpringLayout.NORTH definition code for javax.swing.SpringLayout.NORTH , SOUTH sample code for javax.swing.SpringLayout.SOUTH definition code for javax.swing.SpringLayout.SOUTH , EAST sample code for javax.swing.SpringLayout.EAST definition code for javax.swing.SpringLayout.EAST , WEST sample code for javax.swing.SpringLayout.WEST definition code for javax.swing.SpringLayout.WEST

layoutContainer sample code for javax.swing.SpringLayout.layoutContainer(java.awt.Container) definition code for javax.swing.SpringLayout.layoutContainer(java.awt.Container)

public void layoutContainer(Container sample code for java.awt.Container definition code for java.awt.Container  parent)
Description copied from interface: LayoutManager sample code for java.awt.LayoutManager.layoutContainer(java.awt.Container) definition code for java.awt.LayoutManager.layoutContainer(java.awt.Container)
Lays out the specified container.

Specified by:
layoutContainer sample code for java.awt.LayoutManager.layoutContainer(java.awt.Container) definition code for java.awt.LayoutManager.layoutContainer(java.awt.Container) in interface LayoutManager sample code for java.awt.LayoutManager definition code for java.awt.LayoutManager
Parameters:
parent - the container to be laid out