nl.lxtreme.ols.util.swing
Class SpringLayoutUtils

java.lang.Object
  extended by nl.lxtreme.ols.util.swing.SpringLayoutUtils

public final class SpringLayoutUtils
extends Object

A 1.4 file that provides utility methods for creating form- or grid-style layouts with SpringLayout. These utilities are used by several programs, such as SpringBox and SpringCompactGrid.


Field Summary
static String SEPARATOR
           
 
Method Summary
static Container addSeparator(Container aContainer, String aText)
          Adds a labeled separator to the given container.
static void addToConstraint(SpringLayout.Constraints aConstraints, String aEdgeName, int aConstant)
          Adds a constant value to a given edge of a given constraints.
static void makeCompactGrid(Container aContainer, int aRows, int aCols, int aInitialX, int aInitialY, int aXpad, int aYpad)
          Aligns the first rows * cols components of parent in a grid.
static void makeEditorGrid(Container aContainer, int aInitialX, int aInitialY)
          Makes a compact grid for use in "editors", in which a grid of two columns is created.
static void makeGrid(Container aContainer, int aRows, int aCols, int aInitialX, int aInitialY, int aXpad, int aYpad)
          Aligns the first rows * cols components of parent in a grid.
static JComponent setSeparatorProperty(JComponent aComponent)
          Marks the given component as "separator" component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEPARATOR

public static final String SEPARATOR
See Also:
Constant Field Values
Method Detail

addSeparator

public static final Container addSeparator(Container aContainer,
                                           String aText)
Adds a labeled separator to the given container.

Parameters:
aContainer - the container to add the separator + label to, cannot be null.
aText - the (optional) text of the label to add, may be null.
Returns:
the given container, never null.

addToConstraint

public static void addToConstraint(SpringLayout.Constraints aConstraints,
                                   String aEdgeName,
                                   int aConstant)
Adds a constant value to a given edge of a given constraints.

Parameters:
aConstraints - the constraints to mutate;
aEdgeName - the name of the edge to mutate;
aConstant - the new value to set.

makeCompactGrid

public static void makeCompactGrid(Container aContainer,
                                   int aRows,
                                   int aCols,
                                   int aInitialX,
                                   int aInitialY,
                                   int aXpad,
                                   int aYpad)
Aligns the first rows * cols components of parent in a grid. Each component in a column is as wide as the maximum preferred width of the components in that column; height is similarly determined for each row. The parent is made just big enough to fit them all.

Parameters:
aContainer - the container to layout. Must have a SpringLayout as layout manager;
aRows - number of rows
aCols - number of columns
aInitialX - x location to start the grid at
aInitialY - y location to start the grid at
aXpad - x padding between cells
aYpad - y padding between cells

makeEditorGrid

public static void makeEditorGrid(Container aContainer,
                                  int aInitialX,
                                  int aInitialY)
Makes a compact grid for use in "editors", in which a grid of two columns is created.

Parameters:
aContainer - the container to layout. Must have a SpringLayout as layout manager;
aInitialX - the initial X-padding (left side);
aInitialY - the initial Y-padding (top side).
See Also:
makeCompactGrid(Container, int, int, int, int, int, int)

makeGrid

public static void makeGrid(Container aContainer,
                            int aRows,
                            int aCols,
                            int aInitialX,
                            int aInitialY,
                            int aXpad,
                            int aYpad)
Aligns the first rows * cols components of parent in a grid. Each component is as big as the maximum preferred width and height of the components. The parent is made just big enough to fit them all.

Parameters:
aContainer - the container to layout. Must have a SpringLayout as layout manager;
aRows - number of rows
aCols - number of columns
aInitialX - x location to start the grid at
aInitialY - y location to start the grid at
aXpad - x padding between cells
aYpad - y padding between cells

setSeparatorProperty

public static JComponent setSeparatorProperty(JComponent aComponent)
Marks the given component as "separator" component.

Parameters:
aComponent - the component to mark as "separator", cannot be null.
Returns:
the given component.


Copyright © 2012 L'Xtreme IT consultancy. All Rights Reserved.