java-springlayout

A SpringLayout arranges the children of its associated container according to a set of constraints.Constraints are nothing but horizontal and vertical distance between two component edges. Every constrains are represented by a SpringLayout.Constraint object.

Each child of a SpringLayout container, as well as the container itself, has exactly one set of constraints associated with them.

Each edge position is dependent on the position of the other edge. If a constraint is added to create new edge than the previous binding is discarded. SpringLayout doesn't automatically set the location of the components it manages.

Each edge position is dependent on the position of the other edge. If a constraint is added to create new edge than the previous binding is discarded. SpringLayout doesn't automatically set the location of the components it manages.

Nested Classes

Static class

SpringLayout.Constraints

It is a Constraints object helps to govern component's size and position change in a container that is controlled by SpringLayout

Fields

Method and type Class Description
static String BASELINE It specifies the baseline of a component.
static String EAST It specifies the right edge of a component's bounding rectangle.
static String HEIGHT It specifies the height of a component's bounding rectangle.
static String HORIZONTAL_CENTER It specifies the horizontal center of a component's bounding rectangle.
static String NORTH It specifies the top edge of a component's bounding rectangle.
static String SOUTH It specifies the bottom edge of a component's bounding rectangle.
static String VERTICAL_CENTER It specifies the left edge of a component's bounding rectangle.
static String WEST It specifies the vertical center of a component's bounding rectangle.
static String WIDTH It specifies the width of a component's bounding rectangle.

Useful Methods

Method and type Class Description
Method and type Class Description
void addLayoutComponent(Component component, Object constraints) It returns the spring controlling the distance between the specified edge of the component and the top or left edge of its parent
void addLayoutComponent(String name, Component c) It returns the constraints for the specified component.
Spring getConstraint(String edgeName, Component c) It returns 0.5f (centered).
SpringLayout.Constraints getConstraints(Component c) It returns 0.5f (centered).
float getLayoutAlignmentX(Container p) It Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
void getLayoutAlignmentY(Container p) It lays out the specified container.
void invalidateLayout(Container p)
Dimension layoutContainer(Container parent) It is used to calculates the maximum size dimensions for the specified container, given the components it contains.
Dimension maximumLayoutSize(Container parent) It is used to calculates the preferred size dimensions for the specified container, given the components it contains.
Dimension minimumLayoutSize(Container parent)) It is used to calculates the preferred size dimensions for the specified container, given the components it contains.

Example

Flash Soon



Copyright ©2017 Design& develop