Class tea.set.Grid
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class tea.set.Grid

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----tea.set.Grid

public class Grid
extends Panel
implements Scrollable
Grid widget provides a flexible interface for managing grid layout. A cell in the grid can be any AWT components, and any components derived from the basic AWT components.

There are two ways of managing the space assignment. If absolute is set to false, which is the default, cells are resized to fit the display area. In this mode, the space assignment for rows and columns are automatic based on the preferred size of row and columns. The preferred size of a grid is the sum of preferred row heights and sum of preferred column widths. A preferred row height is the maximum preferred height of any components in a row, and similarly for preferred column width. The automatic space assignment can be overriden by calling setRowHeight() and setColWidth() methods.

Alternatively, a Grid can be set to absolute mode. In this mode cells are not resized to fit the screen. Instead, they are sized to their preferred row and column size. Notice since all cells on a row share same height and all cells on a column share same width, cells ARE resized to their preferred row height and preferred column width, as defined above. But no effort is made to fit all cells into the display area. This mode is primarily for scrolling.

Users can resize rows or columns by dragging ruling lines separating rows and columns. If this happens, the layout mode of the Grid switches to absolute and row height/column width override mode automatically. This means no effort will be made by the Grid to layout cells to make everything fit into the display area from the point on. To disable user resizing, set resizable to false using setResizable().

To enable scrolling of Grid, simply attach a Scroller to the Grid widget. Since Grid implements the Scrollable interface, the scrolling will be by row and column instead of pixels. When a Scroller is attached to the Grid, the Grid is automatically switched to absolute mode.

Rows and columns can be selected by users. If row or column is selectable, a row/column selector header will be displayed. Users can click on the header to select or unselect a row or a column. If multiSelect option is true, more than one row and column can be selected. Otherwise only one selection can exists at one time. Arrow keys can be used to move the row/column selections respectively if one is already selected.

If row/column selectors is not appropriate for an application, you can make row/column selectable without creating selector headers. To avoid selectors to be created, use Grid.setRowSelectable(true, false) and Grid.setColSelectable(true, false). In this case, a mouse click inside any cell will select the row if row is selectable, or select the column if row is not selectable and column is selectable. Note however most Java standard AWT component does not pass up the mouse events, therefore mouse clicks inside those components are not detected by the Grid. Consequently the row/column selection can not be made by clicking mouse in them. Most Tea Set Widget Collection components pass all events up to parent.

Note the row/column selector setting in Grid.setRowSelectable() and Grid.setColSelectable() only controls the creation of the row/column selectors. If row/column headers are set using Grid.setRowHeader() or Grid.setColHeader(), the headers are always able to be used for selecting row/column, regardless the flag values in the Grid.setRowSelectable() and Grid.setColSelectable().

A grid can be optionally drawn. There are two options available. VERTICAL option draws vertical lines between columns. HORIZONTAL option draws horizontal lines between rows. These options can be combined by bitwise OR them together. ALL flag is supplied to enable both grid lines.

The lines in a grid can be drawn in three different styles. The line style is controlled by the set3D() method. If PLAIN is specified, a single pixel line is drawn. If RAISED is specified, the line will be drawn in a 3D style raised above the grid surface. If LOWERED is specified, the line will be drawn in a 3D style embedded into the surface of the grid.

Row and column headers can be specified. If row headers are specified and row is selectable, then the row header is also the row selector. If row is selectable but there is not row header, then an empty row selector is added for each row. The same rule is used for column header and column selector. Row/column header is independent of row/column selectable setting. However, if row/column is selectable, the row/column header will always serve as row/column selector.

Row and column can be dynamically inserted or removed from the grid. When a row/column is inserted, the cells in the row/column are empty. User must call setCell() method to add components to the cells to make the row/column visible. Row and column can also be moved dynamically. When rows/columns are moved, all information about the row/column, such as select status, color, size, are carried with the moved row/column.

One or more rows and/or columns can be hiden. If a row or a column is hiden, it will not be displayed in the grid. However, the numbering of rows and columns will not change. For example, if row 2 is hiden, only rows 0, 1, 3, ... are displayed on screen. The original row 3 will remain row number 3 and will not be renumbered to row 2. The same is true for columns.

Spanning cells are supported. A spanning cell is a cell that takes more than one rows and/or columns. A spanning cell can be added to the grid using setCell(int, int, Component, int, int) method. When inserting or deleting row/column, the insertion or deletion point should not be at the middle of a spanning cell. Otherwise the screen layout will be not correct after the operation.

Color of rows and columns can be set using setRowColor() or setColColor(). An individual cell's color can be set using setColor(). When a cell's color is set using one of the above methods, the background color of the component inside the cell is changed to the color, in addition the cell will be filled with the cell color if cell component does not take all space inside the cell. The foreground of a cell can be changed through the Component interface of the cell component. If cell background color is not set using the methods mentioned above, the cell area is not painted if there is no component in the cell, and the areas leftover by a component inside a cell is not painted neither.

Cell components can be aligned in many different ways. The default cell alignment resize a cell component to fit the entire cell area. User can override this behavior by setting cell alignment explicitly. There are 15 possible alignments. Horizontally, you can choose from H_LEFT, H_CENTER, H_RIGHT. Vertically, you can choose from V_TOP, V_CENTER, and V_BOTTOM. The two can be bitwise or'ed to produce an alignment, or used by itself. If only one direction is specified, the other direction is to fit. For example, if alignment is set to V_TOP, the cell component is going to be aligned to the top of the cell area, and the width of the component is resized to the same width as the cell area.

Known Bug:

On Solaris, there is no way to force a component to the front when one overlays another. Therefore the resize line may or may not be visible when resizing row/column (It may be hiden by other cell components).

Netscape 2.x has a bug causing components inside grid to change location undetectedly. This may cause strange behavior inside a grid. This bug is fixed in Netscape 3.0.

See Also:
Scroller, TextGrid

Variable Index

 o ALL
Draw both horizontal and vertical ruling lines.
 o CENTER_BOTTOM
Center and bottom alignment.
 o CENTER_CENTER
Center and center alignment.
 o CENTER_TOP
Center and top alignment.
 o FILL
Resize the component to fill the cell.
 o H_CENTER
Center at horizontal direction.
 o H_LEFT
Alignment flag determines how the cell components are aligned inside a cell.
 o H_RIGHT
Right align at horizontal direction.
 o HORIZONTAL
Draw horizontal lines between rows.
 o LEFT_BOTTOM
Left and bottom alignment.
 o LEFT_CENTER
Left and center alignment.
 o LEFT_TOP
Left and top alignment.
 o LOWERED
Draw lowered 3D lines.
 o NONE
Don't draw any ruling.
 o PLAIN
Non-3D mode.
 o RAISED
Draw raised 3D lines.
 o RIGHT_BOTTOM
Right and bottom alignment.
 o RIGHT_CENTER
Right and center alignment.
 o RIGHT_TOP
Right and top alignment.
 o V_BOTTOM
Bottom align at vertical direction.
 o V_CENTER
Center at vertical direction.
 o V_TOP
Top align at vertical direction.
 o VERTICAL
Draw vertical lines between columns.

Constructor Index

 o Grid(int, int)
Construct a grid with row rows and col columns.
 o Grid(int, int, int)
Construct a grid with specified number of rows and columns.

Method Index

 o addCol()
Add one column at the end of grid.
 o addCol(int)
Add specified number of columns at the end of grid.
 o addRow()
Add one row at the end of the grid.
 o addRow(int)
Add specified number of rows at the end of grid.
 o clearColHeader()
Clear column headers.
 o clearRowHeader()
Clear row headers.
 o countCols()
Return the number of columns in the grid (excluding header column).
 o countRows()
Return the number of rows in the grid (excluding header row).
 o get3D()
Return the line 3D mode.
 o getCell(int, int)
Return the component at cell.
 o getColRoot()
Return the current col root.
 o getFillHGap()
Return true if fill gap mode is true for horizontal gap.
 o getFillVGap()
Return true if fill gap mode is true for vertical gap.
 o getHeaderRuling()
Return the current header ruling style.
 o getHGap()
Return the horizontal gap between cells.
 o getIncrement(int, int)
Get the increment for scrollbars.
 o getMaximum(int)
Return scrollbar maximum (columns).
 o getMinimum(int)
Return scrollbar minimum (columns).
 o getRowRoot()
Return the current row root.
 o getRuling()
Return the current ruling style.
 o getSelectedCol()
Return the selected column index.
 o getSelectedCols()
Return all selected column indexes.
 o getSelectedRow()
Return the selected row index.
 o getSelectedRows()
Return all selected row indexes.
 o getValue(int)
Return the current value of the specified scrollbar.
 o getVGap()
Return the vertial gap between cells.
 o getVisible(int)
Get the visible portion for the specified direction.
 o handleEvent(Event)
If a Scroller is attached to this Grid, Scroller.notifyUpdate() will be called whenever the layout of this Grid changes.
 o hideCol(int)
Hide a column from the grid.
 o hideRow(int)
Hide a row from the grid.
 o insertCol(int)
Insert one column at the specified position.
 o insertCol(int, int)
Insert specified number of columns at the position specified.
 o insertRow(int)
Insert one row at the specified position.
 o insertRow(int, int)
Insert specified number of rows at the position specified.
 o isAbsolute()
Return true if absolute mode is set to true.
 o isColSelectable()
Return true if column is selectable.
 o isHidenCol(int)
Return true if the specified column is hiden.
 o isHidenRow(int)
Return true if the specified row is currently hiden.
 o isMultiSelect()
Return true if multiSelect is enabled.
 o isResizable()
Return user resize flag.
 o isRowSelectable()
Return true if row is selectable.
 o isSelectedCol(int)
Return true if specified column is selected.
 o isSelectedRow(int)
Return true if specified row is selected.
 o layout()
Layout headers as well as body grid.
 o moveCol(int, int)
Move a col from one position to a new position.
 o moveRow(int, int)
Move a row from one position to a new position.
 o registerScroller(Scroller)
This function is called by Scroller at initialization time.
 o removeCol(int)
Remove specified column.
 o removeCol(int, int)
Remove specified number of columns at the position specified.
 o removeRow(int)
Remove the specified row.
 o removeRow(int, int)
Remove specified number of rows at the position specified.
 o selectCol(int)
Select a column.
 o selectRow(int)
Select a row.
 o set3D(int)
Set the line 3D mode.
 o setAbsolute(boolean)
If absolute is set to true, cells will not be resized to fit the area.
 o setAlignment(int)
Set the alignment for the grid.
 o setAlignment(int, int, int)
Set the alignment for a particular cell.
 o setCell(int, int, Component)
Set the component for a grid cell.
 o setCell(int, int, Component, int, int)
Set the component for a spanning cell.
 o setCell(int, int, String)
Set the component for a cell.
 o setCol(int, String)
Set the entire column to the component.
 o setColAlignment(int, int)
Set the alignment for a particular column.
 o setColColor(int, Color)
Set the column color.
 o setColHeader(int, String)
Set one column header.
 o setColHeader(String, String)
Set column headers.
 o setColHeader(String[])
Set column headers.
 o setColor(int, int, Color)
Set the specified cell to the color.
 o setColRoot(int)
Set the col root.
 o setColSelectable(boolean)
Set column selectable to true or false.
 o setColSelectable(boolean, boolean)
Set column selectable to true or false.
 o setColWidth(int)
Set all column to the specified width.
 o setColWidth(int[])
Set the width for columns in the grid.
 o setFillGap(boolean, boolean)
If the preferred size of rows and cols are less then the size of the widget, fill the gaps so the components will not be stretched.
 o setGap(int, int)
Set the horizontal and vertical gaps between cells in the grid.
 o setHeaderRuling(int)
Set the header ruling style.
 o setMultiSelect(boolean)
Set multiSelect mode to true or false.
 o setResizable(boolean)
Enable/disable user resize through dragging ruling lines.
 o setRow(int, String)
Set the entire row to the component.
 o setRowAlignment(int, int)
Set the alignment for a particular row.
 o setRowColor(int, Color)
Set the row color.
 o setRowHeader(int, String)
Set one row header.
 o setRowHeader(String, String)
Set row headers.
 o setRowHeader(String[])
Set row headers.
 o setRowHeight(int)
Set all rows to the specified height.
 o setRowHeight(int[])
Explicitly specify the row heights in the grid.
 o setRowRoot(int)
Set the row root.
 o setRowSelectable(boolean)
Set row selectable to true or false.
 o setRowSelectable(boolean, boolean)
Set row selectable to true or false.
 o setRuling(int)
Set the ruling style.
 o setSpanning(int, int, int, int)
Set the spanning cell size.
 o setValue(int, int)
Scroll the grid according to scrollbar value.
 o showCol(int)
Show a column if it's currently hiden.
 o showRow(int)
Show a row if the row is currently hiden.
 o unselectCol(int)
Unselect a column.
 o unselectRow(int)
Unselect a row.

Variables

 o NONE
  public final static int NONE
Don't draw any ruling.
 o HORIZONTAL
  public final static int HORIZONTAL
Draw horizontal lines between rows.
 o VERTICAL
  public final static int VERTICAL
Draw vertical lines between columns.
 o ALL
  public final static int ALL
Draw both horizontal and vertical ruling lines.
 o PLAIN
  public final static int PLAIN
Non-3D mode.
 o RAISED
  public final static int RAISED
Draw raised 3D lines.
 o LOWERED
  public final static int LOWERED
Draw lowered 3D lines.
 o H_LEFT
  public final static int H_LEFT
Alignment flag determines how the cell components are aligned inside a cell. The default is FILL. You can use either the final flags, e.g. LEFT_TOP, which is a product of OR of H_ and V_ flags. Or you can compose the flags using H_ and V_ flags explicitly. For example, if H_LEFT is passed as the alignment, the cell will be aligned to the left of the cell space, and the height of the cell component will be stretched to fit the cell height, and the cell component with will be the preferred width of the component if it's less than the cell space width. If LEFT_TOP is used, which is equivalent to H_LEFT|V_TOP, the cell component will be aligned to top left of cell space, and the component will not be stretched to fit neither dimension of the cell space.
 o H_CENTER
  public final static int H_CENTER
Center at horizontal direction.
 o H_RIGHT
  public final static int H_RIGHT
Right align at horizontal direction.
 o V_TOP
  public final static int V_TOP
Top align at vertical direction.
 o V_CENTER
  public final static int V_CENTER
Center at vertical direction.
 o V_BOTTOM
  public final static int V_BOTTOM
Bottom align at vertical direction.
 o FILL
  public final static int FILL
Resize the component to fill the cell.
 o LEFT_TOP
  public final static int LEFT_TOP
Left and top alignment.
 o LEFT_CENTER
  public final static int LEFT_CENTER
Left and center alignment.
 o LEFT_BOTTOM
  public final static int LEFT_BOTTOM
Left and bottom alignment.
 o CENTER_TOP
  public final static int CENTER_TOP
Center and top alignment.
 o CENTER_CENTER
  public final static int CENTER_CENTER
Center and center alignment.
 o CENTER_BOTTOM
  public final static int CENTER_BOTTOM
Center and bottom alignment.
 o RIGHT_TOP
  public final static int RIGHT_TOP
Right and top alignment.
 o RIGHT_CENTER
  public final static int RIGHT_CENTER
Right and center alignment.
 o RIGHT_BOTTOM
  public final static int RIGHT_BOTTOM
Right and bottom alignment.

Constructors

 o Grid
  public Grid(int row,
              int col)
Construct a grid with row rows and col columns. The grid is empty after construction.
Parameters:
row - number of rows.
col - number of columns.
 o Grid
  public Grid(int row,
              int col,
              int ruling)
Construct a grid with specified number of rows and columns. A ruling is explicitly supplied. It can be VERTICAL, HOTIZONTAL, or ALL.
Parameters:
row - number of rows.
col - number of columns.
ruling - ruling style flag.

Methods

 o setCell
  public void setCell(int r,
                      int c,
                      Component cell)
Set the component for a grid cell. If a component is already attached to the cell, it will be removed from the grid and replaced with the new component. If the cell component is null, the specified cell will be cleared if there is existing component inside the cell.
Parameters:
r - row number.
c - column number.
cell - cell component.
 o setCell
  public void setCell(int r,
                      int c,
                      Component cell,
                      int spanRow,
                      int spanCol)
Set the component for a spanning cell. If a component is already attached to the cell, it will be removed from the grid and replaced with the new component. The spanning cell occupies number of rows and columns specified by spanRow and spanCol. The spanRow and spanCol parameters must both be greater than zero.
Parameters:
r - row number.
c - column number.
cell - cell component.
spanRow - number of rows for spanning cell.
spanCol - number of columns for spanning cell.
 o setCell
  public void setCell(int r,
                      int c,
                      String component)
Set the component for a cell. The component parameter must be a valid class name for a class derived from java.awt.Component.
Parameters:
r - row number.
c - column number.
component - the fully qualified name of a class to serve as the cell component.
 o setSpanning
  public void setSpanning(int r,
                          int c,
                          int spanRow,
                          int spanCol)
Set the spanning cell size. The spanRow and spanCol must be greater than zero.
Parameters:
r - row number.
c - column number.
spanRow - number of rows for spanning cell.
spanCol - number of columns for spanning cell.
 o setRow
  public void setRow(int r,
                     String component)
Set the entire row to the component. The component parameter must be a valid class name for a class derived from java.awt.Component.
Parameters:
r - row number.
component - a fully qualified name of a class.
 o setCol
  public void setCol(int c,
                     String component)
Set the entire column to the component. The component parameter must be a valid class name for a class derived from java.awt.Component.
Parameters:
c - column number.
component - a fully qualified name of a class.
 o getCell
  public Component getCell(int r,
                           int c)
Return the component at cell. If not component is attached to the cell, a null will be returned.
Parameters:
r - row number.
c - column number.
Returns:
cell component.
 o countRows
  public int countRows()
Return the number of rows in the grid (excluding header row).
Returns:
number of rows in grid.
 o countCols
  public int countCols()
Return the number of columns in the grid (excluding header column).
Returns:
number of columns in grid.
 o setAlignment
  public void setAlignment(int alignment)
Set the alignment for the grid. Previously set alignment flag is not affected. Subsequent cells will use this alignment flag.
Parameters:
alignment - cell alignment flag.
 o setAlignment
  public void setAlignment(int r,
                           int c,
                           int alignment)
Set the alignment for a particular cell. Alignments of subsequent cells added to the grid will not be affected by this call.
Parameters:
r - row number.
c - column number.
alignment - cell alignment flag.
 o setRowAlignment
  public void setRowAlignment(int r,
                              int alignment)
Set the alignment for a particular row. This method sets all cells in the specified row to the supplied alignment. Alignments of subsequent cells added to the grid will not be affected by this call.
Parameters:
r - row number.
alignment - cell alignment flag.
 o setColAlignment
  public void setColAlignment(int c,
                              int alignment)
Set the alignment for a particular column. This method sets all cells in the specified column to the supplied alignment. Alignments of subsequent cells added to the grid will not be affected by this call.
Parameters:
c - column number.
alignment - cell alignment flag.
 o setRowColor
  public void setRowColor(int r,
                          Color color)
Set the row color. This method sets all cells on the specified row to the color.
Parameters:
r - row number.
color - row color. Clear the row color if null.
 o setColColor
  public void setColColor(int c,
                          Color color)
Set the column color. This method sets all cells on the specified column to the color.
Parameters:
r - column number.
color - column color. Clear the column color if null.
 o setColor
  public void setColor(int r,
                       int c,
                       Color color)
Set the specified cell to the color. It clears the explicit color if color parameter is null, in which case the cell component's own color is used. The different between setting color using Grid.setColor(), Grid.setRowColor(), or Grid.setColColor(), and setting color through the Component interface of cell component is: 1. If there are gaps in a cell, the color in the gap area will not be affected if color is set through Component interface of component cell. 2. If a cell is empty, the color can only be set using Grid.setColor, Grid.setRowColor(), or Grid.setColColor().
Parameters:
r - row number.
c - column number.
color - cell color. Clear explicit color if null.
 o addRow
  public int addRow()
Add one row at the end of the grid. The newly added row is empty initially. Return the row number of the new row.
Returns:
row number of the new row.
 o addRow
  public int addRow(int n)
Add specified number of rows at the end of grid. The newly added rows are empty initially. Consequently, the rows will not show up until components are added to the rows using setCell() method. Return the row number of the new row.
Parameters:
n - number of rows to add.
Returns:
row number of the first new row.
 o insertRow
  public int insertRow(int pos)
Insert one row at the specified position. The newly inserted rows are empty initially. Return the row number of the newly inserted row.
Parameters:
pos - position to insert row.
Returns:
row number of the new row.
 o insertRow
  public synchronized int insertRow(int pos,
                                    int n)
Insert specified number of rows at the position specified. The newly inserted rows are empty initially. Consequently, the rows will not show up until components are added to the rows using setCell() method. Return the row number of the newly inserted rows.
Parameters:
pos - position to insert row.
n - number of rows to add.
Returns:
row number of the first new row.
 o removeRow
  public void removeRow(int pos)
Remove the specified row.
Parameters:
pos - row number.
 o removeRow
  public synchronized void removeRow(int pos,
                                     int n)
Remove specified number of rows at the position specified.
Parameters:
pos - row number.
n - number of rows to remove.
 o moveRow
  public synchronized void moveRow(int from,
                                   int to)
Move a row from one position to a new position. The spanning, alignment, and possible row height override information are carried along. Row selection and row hiding information are correctly maintained.
Parameters:
from - row number to move a row from.
to - row number to move a row to.
 o addCol
  public int addCol()
Add one column at the end of grid. The newly added column is initially empty. Return the column number of added column.
Returns:
column number of the new column.
 o addCol
  public int addCol(int n)
Add specified number of columns at the end of grid. The newly added columns are empty initially. Consequently, the columns will not show up until components are added to the columns using setCell() method. Return the column number of the added column.
Parameters:
n - number of columns.
Returns:
column number of the first new column.
 o insertCol
  public int insertCol(int pos)
Insert one column at the specified position. The newly inserted columns are initially empty initially. Return the column number of the inserted column.
Parameters:
pos - column number.
Returns:
column number of the new column.
 o insertCol
  public synchronized int insertCol(int pos,
                                    int n)
Insert specified number of columns at the position specified. The newly inserted columns are empty initially. Consequently, the columns will not show up until components are added to the columns using setCell() method. Return the column number of the inserted columns.
Parameters:
pos - column number.
n - number of columns.
Returns:
column number of the first new column.
 o removeCol
  public void removeCol(int pos)
Remove specified column.
Parameters:
pos - column number.
 o removeCol
  public synchronized void removeCol(int pos,
                                     int n)
Remove specified number of columns at the position specified.
Parameters:
pos - column number.
n - number of columns.
 o moveCol
  public synchronized void moveCol(int from,
                                   int to)
Move a col from one position to a new position. The spanning, alignment, and possible col width override information are carried along. Column selection and column hiding information are correctly maintained.
Parameters:
from - column number to move a column from.
to - column number to move a column to.
 o setGap
  public void setGap(int h,
                     int v)
Set the horizontal and vertical gaps between cells in the grid. The gaps are added to the right of and below each cell respectively.
Parameters:
h - gap between columns
v - gap between rows.
 o getHGap
  public int getHGap()
Return the horizontal gap between cells.
Returns:
gap between columns.
 o getVGap
  public int getVGap()
Return the vertial gap between cells.
Returns:
gap between rows.
 o setFillGap
  public void setFillGap(boolean h,
                         boolean v)
If the preferred size of rows and cols are less then the size of the widget, fill the gaps so the components will not be stretched. This is only done when no explicit row height or column width is supplied. Note since all components in same row have same heights, and all components in the same column have same width, some components are still going to be stretched if they have different preferred sizes. Fill gap option can be turned on for horizontal gap, vertical gap, or both. The fill option is ignored if absolute flag is set to true.
Parameters:
h - fill gap for horizontal if true.
v - fill gap for vertical if true.
 o getFillHGap
  public boolean getFillHGap()
Return true if fill gap mode is true for horizontal gap.
Returns:
horizontal fill gap mode.
 o getFillVGap
  public boolean getFillVGap()
Return true if fill gap mode is true for vertical gap.
Returns:
vertical fill gap mode.
 o setAbsolute
  public synchronized void setAbsolute(boolean f)
If absolute is set to true, cells will not be resized to fit the area. If user supplied sizes exists, they are treated as absolute pixel size. Otherwise, preferred sizes are used to layout cells. No consideration is given if all cells fits into the area. This mode is automatically enabled when a Scroller is attached to a Grid.
Parameters:
f - true to switch to absolute mode.
 o isAbsolute
  public boolean isAbsolute()
Return true if absolute mode is set to true.
Returns:
absolute mode.
 o setResizable
  public void setResizable(boolean ok)
Enable/disable user resize through dragging ruling lines. If Grid has been resized by user, it will be switched to absolute and row/column size override mode. Setting resizable to false with this function will NOT change the layout mode. In another word, the Grid will stay in absolute and size override mode even resizable is set to false. You need to call setAbsolute(false) and setRowHeight(null) and setColWidth(null) explicitly to restore to default layout mode.
Parameters:
ok - true to enable user resize, false to enable.
 o isResizable
  public boolean isResizable()
Return user resize flag.
Returns:
resizable flag.
See Also:
setResizable
 o setRowHeight
  public void setRowHeight(int h)
Set all rows to the specified height. If absolute is true, this size is the actual pixel size for each row. Otherwise, it simply tells the Grid to set every row to the same size, but the actual height of the rows is dependent on the display area size.
Parameters:
h - row height.
 o setRowHeight
  public void setRowHeight(int rheight[])
Explicitly specify the row heights in the grid. If absolute mode is true, the values in the array is the actual pixel size of each row. Otherwise, the values in the array is the relative proportion of each row. For example, if the argument is {1, 2, 3}, the row 0 will take one sixth of the total grid height, and row 1 will be assigned one third of the total height, and row 2 assigned half of the total height. The space for header or selector is reserved automatically if they exist. If the argument array has less elements than the number of rows, the remaining rows will have the same height as the last row specified in the argument array. Passing a null pointer will cancel row height override mode.
Parameters:
rheight - row heights array.
 o setColWidth
  public void setColWidth(int w)
Set all column to the specified width. Same as setRowHeight(int).
Parameters:
w - column width.
 o setColWidth
  public void setColWidth(int cwidth[])
Set the width for columns in the grid. Please see setRowHeight() for an explanation of the parameter. Pass a null pointer will cancel column width override mode.
Parameters:
cwidth - column width array.
 o setRuling
  public void setRuling(int ruling)
Set the ruling style. The argument can be a product of bitwise OR of the available flags. For example, HORIZONTAL|VERTICAL will cause both horizontal and vertical ruling to be drawn.
Parameters:
ruling - ruling flag.
 o getRuling
  public int getRuling()
Return the current ruling style. Use bitwise AND to check if a flag is set.
Returns:
ruling flag.
 o setHeaderRuling
  public void setHeaderRuling(int ruling)
Set the header ruling style. If VERTICAL is set, a ruling line will be drawn for the row header if exists. If HORIZONTAL is set, a ruling line will be drawn for the column header if exists.
Parameters:
ruling - ruling flag.
 o getHeaderRuling
  public int getHeaderRuling()
Return the current header ruling style. Use bitwise AND to check if a flag is set.
Returns:
ruling flag.
 o set3D
  public void set3D(int mode)
Set the line 3D mode. The value can be one of: PLAIN, RAISED, and LOWERED. The mode defaults to RAISED.
Parameters:
mode - 3D mode.
 o get3D
  public int get3D()
Return the line 3D mode.
Returns:
3D mode.
 o setMultiSelect
  public void setMultiSelect(boolean s)
Set multiSelect mode to true or false. If multiSelect is enabled, more than one row and/or column can be selected. Otherwise, only one row or column can be selected at any given time. MultiSelect defaults to false.
Parameters:
true - for multiple select mode.
 o isMultiSelect
  public boolean isMultiSelect()
Return true if multiSelect is enabled.
Returns:
multi-select mode.
 o setRowSelectable
  public void setRowSelectable(boolean s)
Set row selectable to true or false. Selectors may be added to the grid depending on the previous useRowSelector parameter. The default for useRowSelector is true.
Parameters:
s - true to make row selectable.
 o setRowSelectable
  public synchronized void setRowSelectable(boolean s,
                                            boolean useRowSelector)
Set row selectable to true or false. If row is selectable, a row selector will be added to each row if useRowSelector is true. If row headers exist, the row header will serve as the row selector. RowSelectable defaults to false, and useRowSelector defaults to true. If row is selectable and no row selector exists, row can be selected by clicking in any cell inside a row.
Parameters:
s - true to make row selectable.
useRowSelector - create row selector if true.
 o setColSelectable
  public void setColSelectable(boolean s)
Set column selectable to true or false. Selectors may be added to the grid depending on the previous useColSelector parameter. The default for useColSelector is true.
Parameters:
s - true to make column selectable.
 o setColSelectable
  public synchronized void setColSelectable(boolean s,
                                            boolean useColSelector)
Set column selectable to true or false. If column is selectable, a column selector will be added to each column if useColSelector is true. If column headers exist, the column header will serve as the column selector. ColSelectable defaults to false, and useColSelector defaults to true. If column is selectable and no column selector exists, column can be selected by clicking in any cell inside a column.
Parameters:
s - true to make column selectable.
useColSelector - true to create column selector.
 o isRowSelectable
  public boolean isRowSelectable()
Return true if row is selectable.
Returns:
true if row is selectable.
 o isColSelectable
  public boolean isColSelectable()
Return true if column is selectable.
Returns:
true if column is selectable.
 o setColHeader
  public synchronized void setColHeader(int c,
                                        String header)
Set one column header. If column is selectable, the column header also serves as the column selector. Newline '\n' can be embedded inside the header. Text separated by newline are drawn as separate lines.
Parameters:
c - column number.
header - column header string.
 o setColHeader
  public synchronized void setColHeader(String header[])
Set column headers. If column is selectable, the column header also serves as the column selector. Newline '\n' can be embedded inside the header. Text separated by newline are drawn as separate lines.
Parameters:
header - column header string array.
 o setColHeader
  public synchronized void setColHeader(String header,
                                        String delim)
Set column headers. If column is selectable, the column header also serves as the column selector. The header string contains column headers separated by the delimiter specified by delim. Newline '\n' can be embedded inside the header. Text separated by newline are drawn as separate lines.
Parameters:
header - column headers in delimited form.
delim - delimiter.
 o clearColHeader
  public synchronized void clearColHeader()
Clear column headers. If column is not selectable, the header cells will be removed. Otherwise the header label will be cleared.
 o setRowHeader
  public synchronized void setRowHeader(int r,
                                        String header)
Set one row header. If row is selectable, the row header also serves as the row selector. Newline '\n' can be embedded inside the header. Text separated by newline are drawn as separate lines.
Parameters:
r - row number.
header - row header string.
 o setRowHeader
  public synchronized void setRowHeader(String header[])
Set row headers. If row is selectable, the row header also serves as the row selector. Newline '\n' can be embedded inside the header. Text separated by newline are drawn as separate lines.
Parameters:
header - row header string array.
 o setRowHeader
  public synchronized void setRowHeader(String header,
                                        String delim)
Set row headers. If row is selectable, the row header also serves as the row selector. The header string contains row headers separated by the delimiter specified by delim. Newline '\n' can be embedded inside the header. Text separated by newline are drawn as separate lines.
Parameters:
header - row headers in delimited form.
delim - delimiter.
 o clearRowHeader
  public synchronized void clearRowHeader()
Clear row headers. If row is not selectable, the header cells will be removed. Otherwise the header label will be cleared.
 o hideRow
  public synchronized void hideRow(int r)
Hide a row from the grid. Do nothing if the row is already hiden.
Parameters:
r - row number.
 o showRow
  public synchronized void showRow(int r)
Show a row if the row is currently hiden.
Parameters:
r - row number.
 o isHidenRow
  public boolean isHidenRow(int r)
Return true if the specified row is currently hiden.
Parameters:
r - row number.
Returns:
true if row is hiden.
 o hideCol
  public synchronized void hideCol(int c)
Hide a column from the grid. Do nothing if the column is already hiden.
Parameters:
c - column number.
 o showCol
  public synchronized void showCol(int c)
Show a column if it's currently hiden.
Parameters:
c - column number.
 o isHidenCol
  public boolean isHidenCol(int c)
Return true if the specified column is hiden.
Parameters:
c - column number.
Returns:
true if column is hiden.
 o unselectRow
  public synchronized void unselectRow(int r)
Unselect a row.
Parameters:
r - row number.
 o unselectCol
  public synchronized void unselectCol(int c)
Unselect a column.
Parameters:
c - column number.
 o selectRow
  public synchronized void selectRow(int r)
Select a row. If multiSelect is not enabled, this will cause other selections to be cleared.
Parameters:
r - row number.
 o selectCol
  public synchronized void selectCol(int c)
Select a column. If multiSelect is not enabled, this will cause other selections to be cleared.
Parameters:
c - column number.
 o getSelectedRow
  public int getSelectedRow()
Return the selected row index. If more than one row is selected, the first selected row is returned.
Returns:
row number of selected row.
 o getSelectedRows
  public int[] getSelectedRows()
Return all selected row indexes.
Returns:
row numbers of selected rows.
 o getSelectedCol
  public int getSelectedCol()
Return the selected column index. If more than one column is selected, the first selected column is returned.
Returns:
column number of selected column.
 o getSelectedCols
  public int[] getSelectedCols()
Return all selected column indexes.
Returns:
column numbers of selected columns.
 o isSelectedRow
  public boolean isSelectedRow(int r)
Return true if specified row is selected.
Parameters:
r - row number.
Returns:
true if row is selected.
 o isSelectedCol
  public boolean isSelectedCol(int c)
Return true if specified column is selected.
Parameters:
c - column number.
Returns:
true if column is selected.
 o setRowRoot
  public synchronized void setRowRoot(int r)
Set the row root. All rows below row root are displayed. The rows above row root are not. This is used mostly for scrolling.
Parameters:
r - row number.
 o getRowRoot
  public int getRowRoot()
Return the current row root. See setRowRoot() for an explanation of row root.
Returns:
the root row number.
 o setColRoot
  public synchronized void setColRoot(int c)
Set the col root. All cols below col root are displayed. The cols above col root are not. This is used mostly for scrolling.
Parameters:
c - column number.
 o getColRoot
  public int getColRoot()
Return the current col root. See setColRoot() for an explanation of col root.
Returns:
the root column number.
 o layout
  public void layout()
Layout headers as well as body grid.
Overrides:
layout in class Container
 o handleEvent
  public synchronized boolean handleEvent(Event e)
If a Scroller is attached to this Grid, Scroller.notifyUpdate() will be called whenever the layout of this Grid changes.
Parameters:
e - event object.
Overrides:
handleEvent in class Component
 o registerScroller
  public void registerScroller(Scroller scr)
This function is called by Scroller at initialization time. The Grid will call Scroller.notifyUpdate() when scrollbar values need to be recalculated.
Parameters:
scr - Scroller where this grid is attached to.
 o getMinimum
  public int getMinimum(int orientation)
Return scrollbar minimum (columns).
Parameters:
orientation - VERTICAL or HORIZONTAL.
Returns:
minimum scrollbar value for the orientation.
 o getMaximum
  public int getMaximum(int orientation)
Return scrollbar maximum (columns).
Parameters:
orientation - VERTICAL or HORIZONTAL.
Returns:
maximum scrollbar value for the orientation.
 o getValue
  public int getValue(int orientation)
Return the current value of the specified scrollbar.
Parameters:
orientation - VERTICAL or HORIZONTAL.
Returns:
scrollbar value for the orientation.
 o getVisible
  public int getVisible(int orientation)
Get the visible portion for the specified direction. This is only an approximate.
Parameters:
orientation - VERTICAL or HORIZONTAL.
Returns:
scrollbar visible value for the orientation.
 o getIncrement
  public int getIncrement(int orientation,
                          int direction)
Get the increment for scrollbars.
Parameters:
orientation - VERTICAL or HORIZONTAL.
direction - LINE_UP, LINE_DOWN, PAGE_UP, or PAGE_DOWN.
Returns:
scrollbar increments for the orientation.
 o setValue
  public void setValue(int orientation,
                       int v)
Scroll the grid according to scrollbar value.
Parameters:
orientation - VERTICAL or HORIZONTAL.
v - scrollbar value for the orientation.

All Packages  Class Hierarchy  This Package  Previous  Next  Index