cookxml.cookswing.util
Class SpringLayoutUtilities

java.lang.Object
  extended bycookxml.cookswing.util.SpringLayoutUtilities

public class SpringLayoutUtilities
extends Object

This code is from Java Tutorial The source is at http://java.sun.com/docs/books/tutorial/uiswing/layout/example-1dot4/SpringUtilities.java. No copyright or license information was in the source file and it was from the tutorial. Thus assuming I could use it in this program. Below is the original file header. The file is not modified other than reformating white spaces.

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.

TODO: Although algorithm wise is correct, this class fails to address the problem of rounding errors. As the result, sometimes the last row can be mismatched with other rows. The solution to the problem is to force the alignment of edges.

Since:
CookSwing 1.0
See Also:
SpringLayout, SpringGridCreator

Constructor Summary
SpringLayoutUtilities()
           
 
Method Summary
static void makeCompactGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad)
          Aligns the first rows * cols components of parent in a grid.
static void makeGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad)
          Aligns the first rows * cols components of parent in a grid.
static void printSizes(Component c)
          A debugging utility that prints to stdout the component's minimum, preferred, and maximum sizes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpringLayoutUtilities

public SpringLayoutUtilities()
Method Detail

printSizes

public static void printSizes(Component c)
A debugging utility that prints to stdout the component's minimum, preferred, and maximum sizes.


makeGrid

public static void makeGrid(Container parent,
                            int rows,
                            int cols,
                            int initialX,
                            int initialY,
                            int xPad,
                            int yPad)
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:
rows - number of rows
cols - number of columns
initialX - x location to start the grid at
initialY - y location to start the grid at
xPad - x padding between cells
yPad - y padding between cells

makeCompactGrid

public static void makeCompactGrid(Container parent,
                                   int rows,
                                   int cols,
                                   int initialX,
                                   int initialY,
                                   int xPad,
                                   int yPad)
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:
rows - number of rows
cols - number of columns
initialX - x location to start the grid at
initialY - y location to start the grid at
xPad - x padding between cells
yPad - y padding between cells