pagelayout
Class EasyCell

java.lang.Object
  extended by pagelayout.EasyCell

public class EasyCell
extends java.lang.Object

This class contains static methods that provide convenient ways to call the various constructors and createCellGrid methods. These methods can be used be adding the import static pagelayout.EasyCell.* statements to the set of import statements of the calling class.

The various constants for justfication in the class Cell are repeated here with lower case counterparts, with NO_ALIGNMENT replaced by none.

Of special interest are the methods row, row, column, column, grid, which can be called with arbitrary combinations of objects of the type Component as well of the type Cell (rows, columns, grids, gaps, and component cells). Note that the type checking in these methods is performed at run time, and so they should be used with care.

The classes Example2, Example3, Example4, Example5, Example10, illustrate the use of these methods.

An alternative to using these methods is to use the corresponding methods row, row, column, column, grid, that use Cell objects, and wrap components in a cell by using the cell method of this class. This will ensure that type checking as perfromed by the compiler.

For the methods grid and grid, that can be used to create grids, the followin methods are useful:

As an example of all these methods, consider the following scehmatic layout:





With c1, c2, etc. representing the various components, grid may be laid out by the following code:

 
                CellGrid cellgrid=grid(c1,c2,skip(),eol(),
                                       vspan(),row(c3,c4),span(),eol(),
                                       vspan(),c5,span(),span(),eol(),
                                       c6,c7,c8);
        


Field Summary
static int baseline
          Constant for specifying Baseline alignment (for rows).
static int bottom
          Constant for specifying bottom justified vertical alignment.
static int center
          Constant for specifying center justified alignment.
static int justified
          Constant for specifying fully justified alignment.
static int left
          Constant for specifying left justified horizontal alignment.
static int none
          Constant for specifying no alignment.
static int right
          Constant for specifying right justified horizontal alignment.
static int top
          Constant for specifying top justified vertical alignment.
 
Constructor Summary
EasyCell()
           
 
Method Summary
static Cell cell(java.awt.Component c)
          Convenienence cover method for ComponentCell constructor.
static Column column(Cell... c)
          Convenienence cover method for the Column constructor.
static Column column(java.awt.Component... c)
          Convenienence cover method for the Column constructor.
static Column column(int hjust, int vjust, Cell... c)
          Convenienence cover method for the Column constructor.
static Column column(int hjust, int vjust, java.awt.Component... c)
          Convenienence cover method for the Column constructor.
static Column column(int hjust, int vjust, java.lang.Object... objects)
          Create a column from cells or components.
static Column column(java.lang.Object... objects)
          Create a column from cells or components.
static void coverPanel(javax.swing.JPanel panel, javax.swing.JComponent c)
          Effectively replaces a panel by the given component when the panel is placed in a container.
static Cell eol()
          Returns a cell object that must be used to separate the rows in a grid when the grid or grid method is used.
static CellGrid grid(Cell... cells)
          Creates a grid from a list of cells.
static CellGrid grid(java.lang.Object... objects)
          Creates a grid from a list of cells or components.
static Cell hgap(int min)
          Convenienence cover method for the Gap constructor, with the second argument set to true, to return a horizontal gap.
static Cell hgap(int min, int pref, int max)
          Convenienence cover method for the Gap constructor, with the second argument set to true, to return a horizontal gap.
static Cell hspan()
          Returns a cell object that must be used to specify that the previous cell in the current row span the current cell as well when grid or grid method is used.
static Row row(Cell... c)
          Convenienence cover method for the Row constructor.
static Row row(java.awt.Component... c)
          Convenienence cover method for the Row constructor.
static Row row(int hjust, int vjust, Cell... c)
          Convenienence cover method for the Row constructor.
static Row row(int hjust, int vjust, java.awt.Component... c)
          Convenienence cover method for the Row constructor.
static Row row(int hjust, int vjust, java.lang.Object... objects)
          Create a row from cells or components.
static Row row(java.lang.Object... objects)
          Create a row from cells or components.
static void setDimensions(java.awt.Component c, java.awt.Dimension[] dd)
           
static void setDimensions(javax.swing.JComponent c, boolean useRules, int minW, int minH, int maxW, int maxH, int prefW, int prefH)
           
static void setDimensions(javax.swing.JComponent c, int minW, int minH, int maxW, int maxH, int prefW, int prefH)
           
static void setDimensions(javax.swing.JTextField c, int col, int minW, int minH, int maxW, int maxH, int prefW, int prefH)
           
static void setTADimensions(javax.swing.JTextArea c, int rows, int col, int minW, int minH, int maxW, int maxH, int prefW, int prefH)
           
static Cell skip()
          Returns a cell object that must be used to specify that the cell in the current column remain empty when the grid or grid method is used.
static Cell span()
          Returns a cell object that must be used to specify that the previous cell in the current row span the current cell as well when grid or grid method is used.
static Cell vgap(int min)
          Convenienence cover method for the Gap constructor.
static Cell vgap(int min, int pref, int max)
          Convenienence cover method for the Gap constructor.
static Cell vspan()
          Returns a cell object that must be used to specify that the cell in the current column of the previous row span the current cell as well when grid or grid method is used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

none

public static final int none
Constant for specifying no alignment. Same as TOP or LEFT.

See Also:
Constant Field Values

top

public static final int top
Constant for specifying top justified vertical alignment.

See Also:
Constant Field Values

center

public static final int center
Constant for specifying center justified alignment.

See Also:
Constant Field Values

bottom

public static final int bottom
Constant for specifying bottom justified vertical alignment.

See Also:
Constant Field Values

left

public static final int left
Constant for specifying left justified horizontal alignment.

See Also:
Constant Field Values

right

public static final int right
Constant for specifying right justified horizontal alignment.

See Also:
Constant Field Values

justified

public static final int justified
Constant for specifying fully justified alignment.

See Also:
Constant Field Values

baseline

public static final int baseline
Constant for specifying Baseline alignment (for rows).

See Also:
Constant Field Values
Constructor Detail

EasyCell

public EasyCell()
Method Detail

cell

public static Cell cell(java.awt.Component c)
Convenienence cover method for ComponentCell constructor.


row

public static Row row(int hjust,
                      int vjust,
                      java.awt.Component... c)
Convenienence cover method for the Row constructor.


column

public static Column column(int hjust,
                            int vjust,
                            java.awt.Component... c)
Convenienence cover method for the Column constructor.


row

public static Row row(java.awt.Component... c)
Convenienence cover method for the Row constructor.


column

public static Column column(java.awt.Component... c)
Convenienence cover method for the Column constructor.


row

public static Row row(int hjust,
                      int vjust,
                      Cell... c)
Convenienence cover method for the Row constructor.


column

public static Column column(int hjust,
                            int vjust,
                            Cell... c)
Convenienence cover method for the Column constructor.


row

public static Row row(Cell... c)
Convenienence cover method for the Row constructor.


column

public static Column column(Cell... c)
Convenienence cover method for the Column constructor.


eol

public static Cell eol()
Returns a cell object that must be used to separate the rows in a grid when the grid or grid method is used.


row

public static Row row(java.lang.Object... objects)
Create a row from cells or components. Throws an IllegalArgument exception if any other type of object is used as the input.

Parameters:
objects - List of cells or components
Returns:
a row of the input component cells

row

public static Row row(int hjust,
                      int vjust,
                      java.lang.Object... objects)
Create a row from cells or components. Throws an IllegalArgument exception if any other type of object is used as the input.

Parameters:
hjust - horizontal justification for the row
vjust - vertical justification for the row
objects - List of cells or components
Returns:
a row of the input component cells.

column

public static Column column(java.lang.Object... objects)
Create a column from cells or components. Throws an IllegalArgument exception if any other type of object is used as the input.

Parameters:
objects - List of cells or components
Returns:
a column of the input component cells

column

public static Column column(int hjust,
                            int vjust,
                            java.lang.Object... objects)
Create a column from cells or components. Throws an IllegalArgument exception if any other type of object is used as the input.

Parameters:
hjust - horizontal justification for the row
vjust - vertical justification for the row
objects - List of cells or components
Returns:
a column of the input component cells.

span

public static Cell span()
Returns a cell object that must be used to specify that the previous cell in the current row span the current cell as well when grid or grid method is used.


hspan

public static Cell hspan()
Returns a cell object that must be used to specify that the previous cell in the current row span the current cell as well when grid or grid method is used.


vspan

public static Cell vspan()
Returns a cell object that must be used to specify that the cell in the current column of the previous row span the current cell as well when grid or grid method is used.


vgap

public static Cell vgap(int min)
Convenienence cover method for the Gap constructor.


vgap

public static Cell vgap(int min,
                        int pref,
                        int max)
Convenienence cover method for the Gap constructor.


hgap

public static Cell hgap(int min)
Convenienence cover method for the Gap constructor, with the second argument set to true, to return a horizontal gap.


hgap

public static Cell hgap(int min,
                        int pref,
                        int max)
Convenienence cover method for the Gap constructor, with the second argument set to true, to return a horizontal gap.


grid

public static CellGrid grid(Cell... cells)
Creates a grid from a list of cells.

Parameters:
cells - the list of cells in the grid, with each row separated by the cell returned by the eol method of this class.
Returns:
the grid of cells.

grid

public static CellGrid grid(java.lang.Object... objects)
Creates a grid from a list of cells or components.

Parameters:
objects - the list of cells or components in the grid, with each row separated by the cell returned by the eol method of this class.
Returns:
the grid of cells.

skip

public static Cell skip()
Returns a cell object that must be used to specify that the cell in the current column remain empty when the grid or grid method is used.


setDimensions

public static void setDimensions(java.awt.Component c,
                                 java.awt.Dimension[] dd)

setDimensions

public static void setDimensions(javax.swing.JComponent c,
                                 int minW,
                                 int minH,
                                 int maxW,
                                 int maxH,
                                 int prefW,
                                 int prefH)

setDimensions

public static void setDimensions(javax.swing.JComponent c,
                                 boolean useRules,
                                 int minW,
                                 int minH,
                                 int maxW,
                                 int maxH,
                                 int prefW,
                                 int prefH)

setDimensions

public static void setDimensions(javax.swing.JTextField c,
                                 int col,
                                 int minW,
                                 int minH,
                                 int maxW,
                                 int maxH,
                                 int prefW,
                                 int prefH)

setTADimensions

public static void setTADimensions(javax.swing.JTextArea c,
                                   int rows,
                                   int col,
                                   int minW,
                                   int minH,
                                   int maxW,
                                   int maxH,
                                   int prefW,
                                   int prefH)

coverPanel

public static void coverPanel(javax.swing.JPanel panel,
                              javax.swing.JComponent c)
Effectively replaces a panel by the given component when the panel is placed in a container. This is useful for modifying an existing GUI built by a GUI builder that does not allow all possible types of components to be placed in the design.

Parameters:
panel - The panel to be covered.
c - The component that should cover the panel.