pagelayout
Class GridRow

java.lang.Object
  extended by pagelayout.GridRow

public class GridRow
extends java.lang.Object

GridRow is a utility class to make it easier to create a grid. Each row of a grid may be constructed by creating an object of the class GridRow. Components or cells can be added to the row by using one of the add methods of this class. Any of the components or cells can be made to span more than one column by using the span method, and empty columns may be added by using the skip method of this class. Note that a cell or a component in a column may be made to span more than one row by adding the cell CellGrid.VSPANCELL to the column exactly below the spanning cell/component in the next row. Once all the rows have been so created, the createCellGrid(GridRow... rows) method of CellGrid can be used to construct the grid.

See Also:
Example10

Constructor Summary
GridRow()
          Creates the GridRow object, to which components or cells can be added by using one of the add methods of this class.
GridRow(Cell... cells)
          Creates a GridRow object and adds the array of cells specified as inputs.
GridRow(java.awt.Component... components)
          Creates a GridRow object and adds the array of components specified as inputs.
GridRow(int halign, int valign, Cell... cells)
          Creates a GridRow object and adds the array of cells specified as inputs.
GridRow(int halign, int valign, java.awt.Component... components)
          Creates a GridRow object and adds the array of components specified as inputs.
 
Method Summary
 GridRow add(Cell... cells)
          Add an array of cells to the row.
 GridRow add(java.awt.Component... components)
          Add an array of components to the row.
 GridRow add(int halign, int valign, Cell... cells)
          Add an array of cells with specified alignments to the row.
 GridRow add(int halign, int valign, java.awt.Component... components)
          Add an array of components with specified alignments to the row.
protected  Cell[] getCells()
          Used by CellGrid.
protected  byte getHorizontalAlignment(int index)
          Used by CellGrid.
protected  byte getVerticalAlignment(int index)
          Used by CellGrid.
 int size()
          Returns the number of cells in the row.
 GridRow skip(int n)
          Adds empty columns to the row at the current position.
 GridRow span(int n)
          Specifies the number of columns that should be spanned by the current component/cell of the row.
 GridRow spanHorizontal(int n)
          Specifies the number of columns that should be spanned by the current component/cell of the row.
 GridRow spanVertical()
          This method is used to specify that the component/cell in the previous row immediately above the current column of the row shoud span this column.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GridRow

public GridRow()
Creates the GridRow object, to which components or cells can be added by using one of the add methods of this class.


GridRow

public GridRow(java.awt.Component... components)
Creates a GridRow object and adds the array of components specified as inputs.

Parameters:
components - the array of components to be added after creattion of the object.

GridRow

public GridRow(int halign,
               int valign,
               java.awt.Component... components)
Creates a GridRow object and adds the array of components specified as inputs. Each component is added with the specified alignments.

Parameters:
halign - the horizontal alignment of the components
valign - the vertical alignment of the components
components - the array of components to be added after creattion of the object.

GridRow

public GridRow(Cell... cells)
Creates a GridRow object and adds the array of cells specified as inputs.

Parameters:
cells - the array of cells to be added after creattion of the object.

GridRow

public GridRow(int halign,
               int valign,
               Cell... cells)
Creates a GridRow object and adds the array of cells specified as inputs. Each cells is added with the specified alignments.

Parameters:
halign - the horizontal alignment of the cells
valign - the vertical alignment of the cells
cells - the array of cells to be added after creattion of the object.
Method Detail

add

public GridRow add(java.awt.Component... components)
Add an array of components to the row.

Parameters:
components - the array of components to be added.
Returns:
This object.

add

public GridRow add(int halign,
                   int valign,
                   java.awt.Component... components)
Add an array of components with specified alignments to the row.

Parameters:
halign - the horizontal alignment of the components.
valign - the vertical alignment of the components.
components - the arary of components to be added.
Returns:
This object.

add

public GridRow add(Cell... cells)
Add an array of cells to the row.

Parameters:
cells - the array of cells to be added.
Returns:
This object.

add

public GridRow add(int halign,
                   int valign,
                   Cell... cells)
Add an array of cells with specified alignments to the row.

Parameters:
halign - the horizontal alignment of the cells.
valign - the vertical alignment of the cells.
cells - the arary of cells to be added.
Returns:
This object.

span

public GridRow span(int n)
Specifies the number of columns that should be spanned by the current component/cell of the row.

Parameters:
n - (>=2) the number of columns spanned by the current cell/component.
Returns:
This GridRow object.

skip

public GridRow skip(int n)
Adds empty columns to the row at the current position.

Parameters:
n - the number of empty columns to add.
Returns:
This GridRow object.

getCells

protected Cell[] getCells()
Used by CellGrid. The method createCellGrid(GridRow... rows) uses this method to convert a GridRow object to an array of cells.

Returns:
The array of cells in this row.

getVerticalAlignment

protected byte getVerticalAlignment(int index)
Used by CellGrid. The method createCellGrid(GridRow... rows) uses this method to obtain the vertical alignment of the cell at the given index.

Parameters:
index - the index of the cell whose alignment is needed.
Returns:
The vertical alignment of the cell specified by the input.

getHorizontalAlignment

protected byte getHorizontalAlignment(int index)
Used by CellGrid. The method createCellGrid(GridRow... rows) uses this method to obtain the horizontal alignment of the cell at the given index.

Parameters:
index - the index of the cell whose alignment is needed.
Returns:
The horizontal alignment of the cell specified by the input.

size

public int size()
Returns the number of cells in the row.

Returns:
The number of cells in this row.

spanHorizontal

public GridRow spanHorizontal(int n)
Specifies the number of columns that should be spanned by the current component/cell of the row. Same as span.

Parameters:
n - (>=2) the number of columns spanned by the current cell/component.
Returns:
This GridRow object.

spanVertical

public GridRow spanVertical()
This method is used to specify that the component/cell in the previous row immediately above the current column of the row shoud span this column.

Returns:
This GridRow object.