Java Utililty Methods Swing SpringLayout

List of utility methods to do Swing SpringLayout

Description

The list of methods to do Swing SpringLayout are organized into topic(s).

Method

voidfixCellWidth(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad, int[] maxX, int[] maxY)
Aligns the first rows * cols components of parent in a grid.
SpringLayout layout;
try {
    layout = (SpringLayout) parent.getLayout();
} catch (ClassCastException exc) {
    System.err.println("The first argument to makeCompactGrid must use SpringLayout.");
    return;
Spring x = Spring.constant(initialX);
...
SpringLayout.ConstraintsgetConstraintsForCell(int row, int col, Container parent, int cols)
get Constraints For Cell
SpringLayout layout = (SpringLayout) parent.getLayout();
Component c = parent.getComponent(row * cols + col);
return layout.getConstraints(c);
voidmakeGrid(final Container parent, final int rows, final int cols, final int initialX, final int initialY, final int xPad, final int yPad)
Aligns the first rows * cols components of parent in a grid.
SpringLayout layout;
try {
    layout = (SpringLayout) parent.getLayout();
} catch (ClassCastException exc) {
    System.err.println("The first argument to makeGrid must use SpringLayout.");
    return;
Spring xPadSpring = Spring.constant(xPad);
...
voidmakeOneLineGrid(Container parent)
make One Line Grid
makeCompactGrid(parent, 1, parent.getComponentCount(), 10, 0, 10, 10);
voidsingleColumn(final Container container, final int initialY, final int yPad)
single Column
Spring height = Spring.constant(initialY + yPad * container.getComponentCount());
Spring width = Spring.constant(0);
final SpringLayout layout = (SpringLayout) container.getLayout();
Component previous = container;
for (final Component component : container.getComponents()) {
    final Constraints constraints = layout.getConstraints(component);
    width = Spring.max(width, constraints.getWidth());
    height = Spring.sum(height, constraints.getHeight());
...