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
-
ALL
- Draw both horizontal and vertical ruling lines.
-
CENTER_BOTTOM
- Center and bottom alignment.
-
CENTER_CENTER
- Center and center alignment.
-
CENTER_TOP
- Center and top alignment.
-
FILL
- Resize the component to fill the cell.
-
H_CENTER
- Center at horizontal direction.
-
H_LEFT
- Alignment flag determines how the cell components are aligned
inside a cell.
-
H_RIGHT
- Right align at horizontal direction.
-
HORIZONTAL
- Draw horizontal lines between rows.
-
LEFT_BOTTOM
- Left and bottom alignment.
-
LEFT_CENTER
- Left and center alignment.
-
LEFT_TOP
- Left and top alignment.
-
LOWERED
- Draw lowered 3D lines.
-
NONE
- Don't draw any ruling.
-
PLAIN
- Non-3D mode.
-
RAISED
- Draw raised 3D lines.
-
RIGHT_BOTTOM
- Right and bottom alignment.
-
RIGHT_CENTER
- Right and center alignment.
-
RIGHT_TOP
- Right and top alignment.
-
V_BOTTOM
- Bottom align at vertical direction.
-
V_CENTER
- Center at vertical direction.
-
V_TOP
- Top align at vertical direction.
-
VERTICAL
- Draw vertical lines between columns.
-
Grid(int, int)
- Construct a grid with row rows and col columns.
-
Grid(int, int, int)
- Construct a grid with specified number of rows and columns.
-
addCol()
- Add one column at the end of grid.
-
addCol(int)
- Add specified number of columns at the end of grid.
-
addRow()
- Add one row at the end of the grid.
-
addRow(int)
- Add specified number of rows at the end of grid.
-
clearColHeader()
- Clear column headers.
-
clearRowHeader()
- Clear row headers.
-
countCols()
- Return the number of columns in the grid (excluding header column).
-
countRows()
- Return the number of rows in the grid (excluding header row).
-
get3D()
- Return the line 3D mode.
-
getCell(int, int)
- Return the component at cell.
-
getColRoot()
- Return the current col root.
-
getFillHGap()
- Return true if fill gap mode is true for horizontal gap.
-
getFillVGap()
- Return true if fill gap mode is true for vertical gap.
-
getHeaderRuling()
- Return the current header ruling style.
-
getHGap()
- Return the horizontal gap between cells.
-
getIncrement(int, int)
- Get the increment for scrollbars.
-
getMaximum(int)
- Return scrollbar maximum (columns).
-
getMinimum(int)
- Return scrollbar minimum (columns).
-
getRowRoot()
- Return the current row root.
-
getRuling()
- Return the current ruling style.
-
getSelectedCol()
- Return the selected column index.
-
getSelectedCols()
- Return all selected column indexes.
-
getSelectedRow()
- Return the selected row index.
-
getSelectedRows()
- Return all selected row indexes.
-
getValue(int)
- Return the current value of the specified scrollbar.
-
getVGap()
- Return the vertial gap between cells.
-
getVisible(int)
- Get the visible portion for the specified direction.
-
handleEvent(Event)
- If a Scroller is attached to this Grid, Scroller.notifyUpdate()
will be called whenever the layout of this Grid changes.
-
hideCol(int)
- Hide a column from the grid.
-
hideRow(int)
- Hide a row from the grid.
-
insertCol(int)
- Insert one column at the specified position.
-
insertCol(int, int)
- Insert specified number of columns at the position specified.
-
insertRow(int)
- Insert one row at the specified position.
-
insertRow(int, int)
- Insert specified number of rows at the position specified.
-
isAbsolute()
- Return true if absolute mode is set to true.
-
isColSelectable()
- Return true if column is selectable.
-
isHidenCol(int)
- Return true if the specified column is hiden.
-
isHidenRow(int)
- Return true if the specified row is currently hiden.
-
isMultiSelect()
- Return true if multiSelect is enabled.
-
isResizable()
- Return user resize flag.
-
isRowSelectable()
- Return true if row is selectable.
-
isSelectedCol(int)
- Return true if specified column is selected.
-
isSelectedRow(int)
- Return true if specified row is selected.
-
layout()
- Layout headers as well as body grid.
-
moveCol(int, int)
- Move a col from one position to a new position.
-
moveRow(int, int)
- Move a row from one position to a new position.
-
registerScroller(Scroller)
- This function is called by Scroller at initialization time.
-
removeCol(int)
- Remove specified column.
-
removeCol(int, int)
- Remove specified number of columns at the position specified.
-
removeRow(int)
- Remove the specified row.
-
removeRow(int, int)
- Remove specified number of rows at the position specified.
-
selectCol(int)
- Select a column.
-
selectRow(int)
- Select a row.
-
set3D(int)
- Set the line 3D mode.
-
setAbsolute(boolean)
- If absolute is set to true, cells will not be resized to fit the
area.
-
setAlignment(int)
- Set the alignment for the grid.
-
setAlignment(int, int, int)
- Set the alignment for a particular cell.
-
setCell(int, int, Component)
- Set the component for a grid cell.
-
setCell(int, int, Component, int, int)
- Set the component for a spanning cell.
-
setCell(int, int, String)
- Set the component for a cell.
-
setCol(int, String)
- Set the entire column to the component.
-
setColAlignment(int, int)
- Set the alignment for a particular column.
-
setColColor(int, Color)
- Set the column color.
-
setColHeader(int, String)
- Set one column header.
-
setColHeader(String, String)
- Set column headers.
-
setColHeader(String[])
- Set column headers.
-
setColor(int, int, Color)
- Set the specified cell to the color.
-
setColRoot(int)
- Set the col root.
-
setColSelectable(boolean)
- Set column selectable to true or false.
-
setColSelectable(boolean, boolean)
- Set column selectable to true or false.
-
setColWidth(int)
- Set all column to the specified width.
-
setColWidth(int[])
- Set the width for columns in the grid.
-
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.
-
setGap(int, int)
- Set the horizontal and vertical gaps between cells in the grid.
-
setHeaderRuling(int)
- Set the header ruling style.
-
setMultiSelect(boolean)
- Set multiSelect mode to true or false.
-
setResizable(boolean)
- Enable/disable user resize through dragging ruling lines.
-
setRow(int, String)
- Set the entire row to the component.
-
setRowAlignment(int, int)
- Set the alignment for a particular row.
-
setRowColor(int, Color)
- Set the row color.
-
setRowHeader(int, String)
- Set one row header.
-
setRowHeader(String, String)
- Set row headers.
-
setRowHeader(String[])
- Set row headers.
-
setRowHeight(int)
- Set all rows to the specified height.
-
setRowHeight(int[])
- Explicitly specify the row heights in the grid.
-
setRowRoot(int)
- Set the row root.
-
setRowSelectable(boolean)
- Set row selectable to true or false.
-
setRowSelectable(boolean, boolean)
- Set row selectable to true or false.
-
setRuling(int)
- Set the ruling style.
-
setSpanning(int, int, int, int)
- Set the spanning cell size.
-
setValue(int, int)
- Scroll the grid according to scrollbar value.
-
showCol(int)
- Show a column if it's currently hiden.
-
showRow(int)
- Show a row if the row is currently hiden.
-
unselectCol(int)
- Unselect a column.
-
unselectRow(int)
- Unselect a row.
NONE
public final static int NONE
- Don't draw any ruling.
HORIZONTAL
public final static int HORIZONTAL
- Draw horizontal lines between rows.
VERTICAL
public final static int VERTICAL
- Draw vertical lines between columns.
ALL
public final static int ALL
- Draw both horizontal and vertical ruling lines.
PLAIN
public final static int PLAIN
- Non-3D mode.
RAISED
public final static int RAISED
- Draw raised 3D lines.
LOWERED
public final static int LOWERED
- Draw lowered 3D lines.
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.
H_CENTER
public final static int H_CENTER
- Center at horizontal direction.
H_RIGHT
public final static int H_RIGHT
- Right align at horizontal direction.
V_TOP
public final static int V_TOP
- Top align at vertical direction.
V_CENTER
public final static int V_CENTER
- Center at vertical direction.
V_BOTTOM
public final static int V_BOTTOM
- Bottom align at vertical direction.
FILL
public final static int FILL
- Resize the component to fill the cell.
LEFT_TOP
public final static int LEFT_TOP
- Left and top alignment.
LEFT_CENTER
public final static int LEFT_CENTER
- Left and center alignment.
LEFT_BOTTOM
public final static int LEFT_BOTTOM
- Left and bottom alignment.
CENTER_TOP
public final static int CENTER_TOP
- Center and top alignment.
CENTER_CENTER
public final static int CENTER_CENTER
- Center and center alignment.
CENTER_BOTTOM
public final static int CENTER_BOTTOM
- Center and bottom alignment.
RIGHT_TOP
public final static int RIGHT_TOP
- Right and top alignment.
RIGHT_CENTER
public final static int RIGHT_CENTER
- Right and center alignment.
RIGHT_BOTTOM
public final static int RIGHT_BOTTOM
- Right and bottom alignment.
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.
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.
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.
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.
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.
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.
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.
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.
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.
countRows
public int countRows()
- Return the number of rows in the grid (excluding header row).
- Returns:
- number of rows in grid.
countCols
public int countCols()
- Return the number of columns in the grid (excluding header column).
- Returns:
- number of columns in grid.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
removeRow
public void removeRow(int pos)
- Remove the specified row.
- Parameters:
- pos - row number.
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.
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.
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.
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.
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.
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.
removeCol
public void removeCol(int pos)
- Remove specified column.
- Parameters:
- pos - column number.
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.
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.
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.
getHGap
public int getHGap()
- Return the horizontal gap between cells.
- Returns:
- gap between columns.
getVGap
public int getVGap()
- Return the vertial gap between cells.
- Returns:
- gap between rows.
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.
getFillHGap
public boolean getFillHGap()
- Return true if fill gap mode is true for horizontal gap.
- Returns:
- horizontal fill gap mode.
getFillVGap
public boolean getFillVGap()
- Return true if fill gap mode is true for vertical gap.
- Returns:
- vertical fill gap mode.
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.
isAbsolute
public boolean isAbsolute()
- Return true if absolute mode is set to true.
- Returns:
- absolute mode.
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.
isResizable
public boolean isResizable()
- Return user resize flag.
- Returns:
- resizable flag.
- See Also:
- setResizable
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.
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.
setColWidth
public void setColWidth(int w)
- Set all column to the specified width. Same as setRowHeight(int).
- Parameters:
- w - column width.
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.
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.
getRuling
public int getRuling()
- Return the current ruling style. Use bitwise AND to check if a
flag is set.
- Returns:
- ruling flag.
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.
getHeaderRuling
public int getHeaderRuling()
- Return the current header ruling style. Use bitwise AND to check
if a flag is set.
- Returns:
- ruling flag.
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.
get3D
public int get3D()
- Return the line 3D mode.
- Returns:
- 3D mode.
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.
isMultiSelect
public boolean isMultiSelect()
- Return true if multiSelect is enabled.
- Returns:
- multi-select mode.
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.
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.
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.
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.
isRowSelectable
public boolean isRowSelectable()
- Return true if row is selectable.
- Returns:
- true if row is selectable.
isColSelectable
public boolean isColSelectable()
- Return true if column is selectable.
- Returns:
- true if column is selectable.
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.
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.
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.
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.
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.
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.
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.
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.
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.
showRow
public synchronized void showRow(int r)
- Show a row if the row is currently hiden.
- Parameters:
- r - row number.
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.
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.
showCol
public synchronized void showCol(int c)
- Show a column if it's currently hiden.
- Parameters:
- c - column number.
isHidenCol
public boolean isHidenCol(int c)
- Return true if the specified column is hiden.
- Parameters:
- c - column number.
- Returns:
- true if column is hiden.
unselectRow
public synchronized void unselectRow(int r)
- Unselect a row.
- Parameters:
- r - row number.
unselectCol
public synchronized void unselectCol(int c)
- Unselect a column.
- Parameters:
- c - column number.
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.
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.
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.
getSelectedRows
public int[] getSelectedRows()
- Return all selected row indexes.
- Returns:
- row numbers of selected rows.
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.
getSelectedCols
public int[] getSelectedCols()
- Return all selected column indexes.
- Returns:
- column numbers of selected columns.
isSelectedRow
public boolean isSelectedRow(int r)
- Return true if specified row is selected.
- Parameters:
- r - row number.
- Returns:
- true if row is selected.
isSelectedCol
public boolean isSelectedCol(int c)
- Return true if specified column is selected.
- Parameters:
- c - column number.
- Returns:
- true if column is selected.
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.
getRowRoot
public int getRowRoot()
- Return the current row root. See setRowRoot() for an explanation of
row root.
- Returns:
- the root row number.
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.
getColRoot
public int getColRoot()
- Return the current col root. See setColRoot() for an explanation of
col root.
- Returns:
- the root column number.
layout
public void layout()
- Layout headers as well as body grid.
- Overrides:
- layout in class Container
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
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.
getMinimum
public int getMinimum(int orientation)
- Return scrollbar minimum (columns).
- Parameters:
- orientation - VERTICAL or HORIZONTAL.
- Returns:
- minimum scrollbar value for the orientation.
getMaximum
public int getMaximum(int orientation)
- Return scrollbar maximum (columns).
- Parameters:
- orientation - VERTICAL or HORIZONTAL.
- Returns:
- maximum scrollbar value for the orientation.
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.
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.
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.
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