A
JTable
is the interface to the Java Swing JTable Component.
Yoix programs normally interact with a
JTable
using event handlers and by reading or writing the following fields:
| action(int flag[, Object arg1[, Object arg2[, ...]]]) |
A built-in for manipulating the table or getting information about it
and its components.
The initial argument, an integer
flag,
indicates the action to take.
The remaining arguments, if any, depend on the type of action.
The integer flags, which are all defined in
yoix.swing,
their indicated actions and the associated arguments, if any,
are described in the following list.
-
ADD_CELL_SELECTION
changes the selection status of the specified cell or range of cells without
affecting the selection status of any other cells (unless
multiplemode
is set to
SINGLE_SELECTION).
When present, the first pair of
int
arguments represents the row and column
of the cell to affect; an additional pair of
int
arguments permits specification of
a rectangular range of cells to affect.
A trailing
String
argument determines the selection mode
and can take the values "on", "off" or "toggle".
When no
int
arguments are present, all cells are affected.
When no
String
argument is present, the selection mode is "on".
For cell selection to occur, cell selection needs to be activated (see the
CELL_SELECTION
action).
Examples of usage are:
action(ADD_CELL_SELECTION, 2, 3)
action(ADD_CELL_SELECTION, "toggle")
action(ADD_CELL_SELECTION, 1, 1, 4, 3, "off")
-
ADD_COLUMN_SELECTION
changes the selection status of the specified columns without
affecting the selection status of any other columns (unless
multiplemode
is set to
SINGLE_SELECTION).
At least one
int
argument specifying a column to be affected must be present.
If a second
int
argument column specification is present, the two arguments define an
inclusive range of columns to be affected.
A trailing
String
argument determines the selection mode
and can take the values "on", "off" or "toggle".
When no string argument is present, the selection mode is "on".
For column selection to occur, column selection needs to be activated (see the
COLUMN_SELECTION
action).
Examples of usage are:
action(ADD_COLUMN_SELECTION, 2)
action(ADD_COLUMN_SELECTION, 1, 3, "toggle")
action(ADD_COLUMN_SELECTION, 1, "off")
-
ADD_ROW_SELECTION
changes the selection status of the specified rows without
affecting the selection status of any other rows (unless
multiplemode
is set to
SINGLE_SELECTION).
At least one
int
argument specifying a row to be affected must be present.
If a second
int
argument row specification is present, the two arguments define an
inclusive range of rows to be affected.
A trailing
String
argument determines the selection mode
and can take the values "on", "off" or "toggle".
When no string argument is present, the selection mode is "on".
For row selection to occur, row selection needs to be activated (see the
ROW_SELECTION
action).
Examples of usage are:
action(ADD_ROW_SELECTION, 2)
action(ADD_ROW_SELECTION, 1, 3, "toggle")
-
APPEND_ROWS
adds one or more rows after the specified index.
The first argument can be a
String
in the same format as used when assigning to the
text
field, or it can be an
Array
of arrays as used when assigning to the
values
field, or it can be an
Array
of elements describing a single row.
If the first argument is
NULL,
then this action becomes a no-op.
The second argument is an
int
describing the row in the current view after which the new rows should
be placed.
By default, a
SYNCROWVIEWS
is triggered after the add is completed.
Supplying a zero value
int
as a third argument suppresses this behavior.
Examples of usage are:
action(APPEND_ROWS, "one fish|two fish\nred fish|blue fish", 2)
action(APPEND_ROWS, new Array {"one fish", "two fish"}, 4, FALSE)
-
CELL_SELECTION
With no arguments, an
int
is returned indicating, when zero, that cell selection is disabled or,
when non-zero, that cell selection is enabled.
When a single
int
argument is supplied, cell selection is enabled when its value is
non-zero and disabled when its value is zero.
Enabling or disabling both row and column selection (see the
COLUMN_SELECTION
and
ROW_SELECTION
actions) is equivalent to enabling or disabling cell selection.
Disabling either row or column selection disables cell selection.
Setting selectability causes all current selections to be cleared.
-
CLEAR_SELECTION
Clears both the current selection and the find marker, if any.
No arguments are expected.
-
COLUMN_SELECTION
With no arguments, an
int
is returned indicating, when zero, that column selection is disabled or,
when non-zero, that column selection is enabled.
When a single
int
argument is supplied, column selection is enabled when its value is
non-zero and disabled when its value is zero.
Setting selectability causes all current selections to be cleared.
-
DELETE_ROWS
deletes the specified rows from the table.
The first argument can be an
Array,
specifying a set of rows to be deleted, or an
int,
specifying, along with the next argument, an inclusive range of rows to be deleted.
If both integers are the same, a single row is deleted.
Row specifications are in terms of the current table view.
By default, a
SYNCROWVIEWS
is triggered after the deletion is completed.
Supplying a zero value
int
as a last argument suppresses this behavior.
-
EDIT_CANCEL
Resets the current cell being edited back to
the state it was in before any editing changes occurred.
Namely, it undoes any changes that were not committed.
The cell is left in edit mode.
This action takes no arguments.
-
EDIT_GET_CELL
returns a
Dictionary
providing the
valuesColumn,
valuesRow,
viewColumn
and
viewRow
of the current cell editor or
NULL
if no cell is being edited.
-
EDIT_GET_FIELD
returns a
String
that represents the contents of the cell that is currently being edited, or
NULL
if no cell is being edited.
-
EDIT_SET_BACKGROUND
sets the background color used by the current cell editor to the
Color
supplied as the first argument.
-
EDIT_SET_FIELD
uses the first argument, which must be a
String,
Number,
or
NULL,
to store a new value in the table's current cell editor, if there is one.
An optional second argument that is an
int
can be used to set the position of the caret when the current cell editor is a
JTextField,
with
-1
used to try and leave the caret at its current position and
-2
used when the caret position should be selected by carefully comparing the old and new text.
-
EDIT_SET_FOREGROUND
sets the foreground color used by the current cell editor to the
Color
supplied as the first argument.
-
EDIT_START
starts editing the cell at the row and column in the values matrix selected by the two
int
arguments that must follow
EDIT_START.
An additional
int
argument, if supplied and non-zero, means the row and column are indices in the view matrix.
-
EDIT_STOP
Commits editing changes made to the current cell being edited and
takes the cell out of editing mode.
This action takes no arguments.
-
FIND_CELL_AT
returns a
Dictionary
providing the
valuesColumn,
valuesRow,
viewColumn
and
viewRow
of the cell located at the
Point
supplied as an argument.
A value less than zero indicates that no row or no column corresponds
to the supplied y or x value, respectively.
Note, patrial match information, for example a non-negative column
value and a negative row value, is returned as well.
-
GET_CELL_SELECTION
Returns an
Array
of zero or more
Dictionary
objects, one for each selected cell.
Each dictionary has four elements describing the associated cell location
in terms of its position in the values matrix and the view matrix, namely:
valuesColumn,
valuesRow,
viewRow
and
viewColumn.
-
GET_COLUMN
Given a single
int
argument indicating a column number within the values matrix, this action
returns a
JTableColumn
whose fields reflect the current state of the specified column.
See also the
SET_COLUMN
action.
-
GET_COLUMN_DATA_INDEX
Given an
int
argument indicating a column number within the table view,
return the corresponding column index in the values matrix.
See also
GET_COLUMN_VIEW_INDEX,
GET_ROW_DATA_INDEX
and
GET_ROW_VIEW_INDEX.
-
GET_COLUMN_FIELD
Given an
int
argument indicating a column number within the values matrix and a
String
argument that is the name of a field associated with a
JTableColumn,
this action returns the value of the specified column field.
See also the
SET_COLUMN_FIELD
action, where the fields available are explicitly listed.
-
GET_COLUMN_RECT
Given an
int
argument indicating a column number within the values matrix, a
Rectangle
representing the visible rectangle of the specified column excluding its header and
within the context of the table's scroll pane is returned.
-
GET_COLUMN_SELECTION
Returns an
Array
of zero or more
Dictionary
objects, one for each selected column.
Each dictionary has two elements describing the associated column location
in terms of its position in the values matrix and the view matrix, namely:
valuesColumn,
and
viewColumn.
-
GET_COLUMN_VIEW_INDEX
Given an
int
argument indicating a column number within the values matrix,
return the corresponding column index in the table view.
See also
GET_COLUMN_DATA_INDEX,
GET_ROW_DATA_INDEX
and
GET_ROW_VIEW_INDEX.
-
GET_EDITOR_BOX
Given a single
int
argument indicating a column number within the values matrix, this action
returns the
JComboBox,
if any, assigned to the column for selecting and editing values in that
column.
If no
JComboBox
editor is assigned to the column,
NULL
is returned.
See also the
SET_EDITOR_BOX
action.
-
GET_FIELD
Given two
int
arguments representing the row and column, respectively, of a cell
in the values matrix, the value of that cell is returned.
A final optional
String
argument with the value
text
or
value
can be used to determine the format of the return value.
By default, text format is used.
-
GET_FIND_MARKER
Returns either
NULL
or a
Dictionary
containing four elements that described the find marker location
in terms of its position in the values matrix and the view matrix, namely:
valuesColumn,
valuesRow,
viewRow
and
viewColumn.
-
GET_ROW
Given a single
int
argument indicating a row number within the values matrix, this action
returns a
String
containing a concatenation of the text representations for all the table
fields in the row across all the columns.
The delimiter used to separate cells in different columns is determined by
the outputfilter field.
-
GET_ROW_DATA_INDEX
Given an
int
argument indicating a row number within the table view,
return the corresponding row index in the values matrix.
See also
GET_ROW_VIEW_INDEX,
GET_COLUMN_DATA_INDEX
and
GET_COLUMN_VIEW_INDEX.
-
GET_ROW_RECT
Returns the
Rectangle
describing the row indicated by the first
int
argument.
The origin is the upper left corner of the table.
If an optional second
int
argument is non-zero, then the origin is the upper left corner of the screen.
-
GET_ROW_SELECTION
Returns an
Array
of zero or more
Dictionary
objects, one for each selected row.
Each dictionary has two elements describing the associated row location
in terms of its position in the values matrix and the view matrix, namely:
valuesRow,
and
viewRow.
-
GET_ROW_VIEW_INDEX
Given an
int
argument indicating a row number within the table view,
return the corresponding row index in the values matrix.
See also
GET_ROW_VIEW_INDEX,
GET_COLUMN_DATA_INDEX
and
GET_COLUMN_VIEW_INDEX.
-
GET_SELECTED_CELL
returns a
Dictionary
providing the
valuesColumn,
valuesRow,
viewColumn
and
viewRow
of the currently selected cell or
NULL
if no cell is selected.
-
GET_TYPE_FIELD
Given an
int
argument indicating a field type and a
String
argument that is either
alignment
or
attributes,
this action will retrieve the alignment or attribute characteristics of
the specified field type.
Valid field type constants are listed in the
SET_FIELD
action description, below.
-
GET_VISIBLE_RECT
Returns a
Rectangle
representing the visible rectangle of the table's columns excluding its header and
within the context of the table's scroll pane is returned.
-
INSERT_ROWS
behaves like the
APPEND_ROWS
action except that the new rows are placed before the specified index
that is supplied as the second argument.
-
IS_CELL_SELECTED
Given two
int
arguments representing the row and column, respectively, of a cell
in the values matrix, an
int
is returned which is zero if the cell is not selected and non-zero
if it is selected.
-
IS_COLUMN_SELECTED
Given an
int
argument representing a column in the values matrix, an
int
is returned which is zero if the column is not selected and non-zero
if it is selected.
-
IS_ROW_SELECTED
Given an
int
argument representing a row in the values matrix, an
int
is returned which is zero if the row is not selected and non-zero
if it is selected.
-
MAKE_CELL_VISIBLE
Given two
int
arguments representing the row and column, respectively, of a cell
in the values matrix, the table will be scrolled as needed to make sure
the specified cell is visible.
An optional trailing
int
argument
is returned which is zero if the cell is not selected and non-zero
if it is selected.
-
MOVE_COLUMN
Given two
int
arguments representing a starting view column position and a final view column position, respectively,
the view of the table columns will be adjusted accordingly.
If the final position is to the right of the starting position, the intervening columns will be shifted to
the left, and conversely when the column is being moved to the left.
Specifications out of range are silently corrected to the appropriate boundary value and any move with an
identical starting and final position is ignored.
-
REPLACE_ROWS
replaces the specified rows with the new rows
provided.
The first arguments gives the new row information in the same format
as used for the
APPEND_ROWS
action with the exception that a
NULL
value means this action will end up deleting rows as indicated by the next two
arguments.
The second argument is an
int
specifying the row in the current table view after which the given rows are
to be placed just as with the
APPEND_ROWS
action.
A negative value means to insert the rows before the current first row.
If no additional arguments are present, then if the second argument
specifies a row within the current table, that row will be replaced by
the new rows.
If a third argument is present and it is an
int
value, then it is used with the second argument to
specify an inclusive range of rows to be replaced.
If the third argument is present and an
Array
of
int
values, then those values are taken to current rows within the table
that will be deleted after the new rows are placed as indicated by the
second argument.
If the third argument is present, but it is
NULL,
then no rows are deleted so that this
REPLACE_ROWS
action effectively becomes an
APPEND_ROWS
action.
If a fourth argument and final
int
argument is present, then a non-zero value indicates that a
SYNCROWVIEWS
should be performed, which is the default.
Examples of usage are:
action(REPLACE_ROWS, "data", 2)
replaces the third row (row numbering begins at zero) with the given data;
action(REPLACE_ROWS, "data", 2, 4)
replaces the third row through fifth row, inclusive, with the given data;
action(REPLACE_ROWS, "data", 2, new Array[] { 0, 2, 3 })
places the given data after the current third row and deletes the
current first, third and fourth rows;
action(REPLACE_ROWS, null, 2, new Array[] { 0, 2, 3 })
deletes the current first, third and fourth rows.
-
RESET_VIEW
Resets the column view of the data to match the underlying data.
No arguments are expected.
-
ROW_SELECTION
With no arguments, an
int
is returned indicating, when zero, that row selection is disabled or,
when non-zero, that row selection is enabled.
When a single
int
argument is supplied, row selection is enabled when its value is non-zero and
disabled when its value is zero.
Setting selectability causes all current selections to be cleared.
-
ROW_VISIBILITY
This action is used for making rows visible or invisible.
When the first argument is either the
String
value
toggle
or an
int
value to indicate visibility on (non-zero) or visibility off (zero),
then with no additional arguments, the first arguments applies to all rows,
otherwise the second argument can be an
int
specifying a specific row index or an
Array
of integer values specifying a set of row indices.
Otherwise, the first argument could be an
Array
of integers, with non-zero values used to indicate visibility and zero values
used to indicate invisibility.
The offset of an element in the array determines the offset of the row to
be affected, namely the first element affects the first row, the second element
affects the second row and so on.
The number of elements can be less than the number of rows, but it cannot exceed the
number of rows.
In any case, a trailing
String
argument that starts with the word
view
indicates that any row index refers to the current table view, otherwise
the indices refer to rows in the values matrix.
Note that changes in visibility affect the table view, but not the values matrix.
-
SET_CELL_SELECTION
Sets the selection state of the specified cells.
With no arguments, selection state of all cells is affected.
With a pair of
int
arguments which indicate the row and column of a cell within the values matrix,
the state of the specified cell is affected.
With two pairs of
int
arguments indicating the upper-left and lower-right corners of a rectangle
of cells cell within the values matrix,
the state of the specified collection of cells is affected.
If
ROW_SELECTION
is enabled, but
COLUMN_SELECTION
is not, then the entire rows containing the specified cells are affected.
Similarly, if
COLUMN_SELECTION
is enabled, but
ROW_SELECTION
is not, then the entire columns containing the specified cells are affected.
By default, the selection state of the affected cells is turned on, but a
trailing
String
argument can be used to specify the selection state as
on,
off
or
toggle,
where the latter flips the selection state of the affected cells.
This action will clear the current selection, if any.
-
SET_COLUMN_FIELD
This action allows particular fields within the
JTableColumn
structure of the table specified by an initial
int
argument.
The next argument selects the specific field to be modified when its
value is one of the field name string values listed below and the remaining
argument determines the field's new value.
-
alignment
Sets the column alignment by means of one of the keyword constants:
LEFT,
RIGHT
or
CENTER.
-
altalignment
Sets the column header alignment by means of one of the keyword constants:
LEFT,
RIGHT
or
CENTER.
-
altbackground
Sets the background color of the column header.
-
altfont
Sets the font of the column header.
-
altforeground
Sets the foreground (i.e., font) color of the column header.
-
alttooltiptext
Sets the column header tooltip text.
-
attributes
Allows setting of attributes that determine how fields are formatted.
Not all attributes apply to all column data types.
Attributes are set using a
Dictionary
containing one or more attribute identifiers and associated values.
In cases when an attribute has no meaning for the data type being displayed, it is
silently ignored.
Some defaults are determined by the default
Locale
in effect when the table column is created.
The attributes fall into four groups: boolean, double, integer and string.
Boolean attributes accept a zero (false) or non-zero (true)
int
value.
Double attributes accept an
int
or
double
numeric value.
Integer attributes accept an
int
numeric value.
String attributes accept a
String
value.
Boolean attribute identifiers and their function are:
-
decimalSeparatorAlwaysShown
can be used to force display of decimal separator.
-
groupingUsed
determines whether the number is displayed with a separator after each
N non-decimal digits, where N is the value of the
groupingSize
attribute (see below).
-
parseIntegerOnly
used to suppress display of decimal portion of number.
-
zeroNotShown
used to suppress display of zero valued cells.
Double attribute identifiers and their function are:
-
overflow
used to limit display of data values that exceed the specified value.
When the data value exceeds this value, the displayed cell is this value
properly formatted, but with each digit value replaced by an asterisk.
Thus, if this value is
99,
the column is a
MONEY_TYPE
and the data value is 101.15, then
$**.**
will be displayed.
-
underflow
used to limit display of data values fall below the specified value.
When the data value falls below this value, the displayed cell is this value
properly formatted, but with each digit value replaced by an asterisk.
If the data value is negative, the sign will also be displayed.
Thus, if this value is
9.5,
the column is a
MONEY_TYPE
and the data value is -101.15, then
($*.**)
will be displayed.
Integer attribute identifiers and their function are:
-
groupingSize
determines how many non-decimal digits are grouped between separators. For
example, in the USA this size defaults to 3 for thousands, millions, etc.,
where the separator is a comma.
-
maximumFractionDigits
determines the maximum number of fraction (decimal) digits displayed.
-
maximumIntegerDigits
determines the maximum number of non-decimal digits displayed.
-
minimumFractionDigits
determines the minimum number of fraction (decimal) digits displayed.
-
minimumIntegerDigits
determines the minimum number of non-decimal digits displayed.
-
multiplier
multiplies the data value by the supplied positive integer for display
purposes.
String attribute identifiers and their function are:
-
format",
determines the format of the number. The format syntax is determined by the
number type.
For
DATE_TYPE,
the format corresponds to the pattern description
found in the Yoix documentation for
date.
For
TIMER_TYPE,
the format corresponds to the pattern description
found in the Yoix documentation for
timerFormat.
For other numeric types, the format corresponds to the pattern description
found in the Java API documentation for
java.text.DecimalFormat.
-
highSubstitute
defines a string or an array of strings
that when encountered in textual data input for numeric
fields will be substituted internally by large positive values so that
the items will sort to the bottom (increasing sort). The non-numeric remains
as the displayed value (useful for missing data or N/A indicators).
-
inputFormat",
determines the format used when parsing string input for the
DATE_TYPE,
DOUBLE_TYPE,
INTEGER_TYPE,
MONEY_TYPEand
PERCENT_TYPE.
Currently, the
TIMER_TYPE
does not utilize this attribute.
For
DATE_TYPE,
the format corresponds to the pattern description
found in the Yoix documentation for
date.
For the other types, the format corresponds to the pattern description
found in the Java API documentation for
java.text.DecimalFormat.
-
inputLocale
sets the locale used to interpret
DATE_TYPE,
DOUBLE_TYPE,
INTEGER_TYPE,
MONEY_TYPEand
PERCENT_TYPE
input data, when needed.
-
inputTimeZone
sets the timezone used to interpret
DATE_TYPE
input data, when needed.
When no value is supplied, the
Locale
applied when displaying data is used.
-
locale
sets the locale used when displaying
DATE_TYPE,
DOUBLE_TYPE,
INTEGER_TYPE,
MONEY_TYPEand
PERCENT_TYPE
data.
-
lowSubstitute
defines a string or an array of strings
that when encountered in textual data input for numeric
fields will be substituted internally by large negative values so that
the items will sort to the top (increasing sort). The non-numeric remains
as the displayed value (useful for missing data or N/A indicators).
-
negativePrefix
defines the prefix used for negative numbers.
-
negativeSuffix
defines the suffix used for negative numbers.
-
positivePrefix
defines the prefix used for positive numbers.
-
positiveSuffix
defines the suffix used for positive numbers.
-
timeZone
sets the timezone used when displaying
DATE_TYPE
data.
-
background
The
Color
that is used to paint the background of the column when
cellcolors
is
NULL.
Reading returns a snapshot of the current color.
Writing immediately changes the background to the new color,
assuming that it is not superceded by
cellcolors.
-
cellcolors
Sets the background and foreground colors for the column cells by means of
a one or two element
Array.
The first element affects cell background; the second element affects cell
foreground.
Each element can be a
Color
or an
Array
of colors.
When a single color is provided, it applies to all rows within the column.
When an array of colors is provided, each array element
applies to a table row in sequence.
If there are more rows than array elements, the sequencing restarts at the
beginning of the array.
If the array or an element in the array is
NULL
the value determined by the table
cellcolors
field is used.
-
disabledbackground
Takes a
Color
argument and sets the disabled background color within the column accordingly.
-
disabledforeground
Takes a
Color
argument and sets the disabled foreground color within the column accordingly.
-
edit
Sets the editability of the cells in the column.
Either an
int
or an
Array
of integers can be supplied.
A non-zero integer turns on editing, while a zero integer turns off editing.
When a
NULL
value is supplied, the column's editability settings are cleared.
Column editability overrides editability set at the table level using the
edit
field.
-
editbackground
Takes a
Color
argument and sets the edit background color within the column accordingly.
-
editforeground
Takes a
Color
argument and sets the edit foreground color within the column accordingly.
-
font
Sets the font of the column.
-
foreground
The
Color
that is used to paint the foreground of the column when
cellcolors
is
NULL.
Reading returns a snapshot of the current color.
Writing immediately changes the foreground to the new color,
assuming that it is not superceded by
cellcolors.
-
header
Sets the column header text using the supplied
String
argument.
-
headericons
Sets the column header text using the supplied
String
argument.
That argument can be a single
Image
value, an
Array
of three
Image
values or, of course, a
NULL.
When an array of images is supplied, the images correspond to the unsorted,
increasing or decreasing sort state of the column, respectively.
-
selectionbackground
Takes a
Color
argument and sets the selection background color within the column accordingly.
-
selectionforeground
Takes a
Color
argument and sets the selection foreground color within the column accordingly.
-
tag
Takes a
String
argument which can be used to refer to the column in lieu of its
value matrix index.
-
text
Takes a
String
argument containing new values for the row elements in the specified
column with each value separated by the
outputfilter
record delimiter.
-
tooltiptext
takes a
String
or
Array
argument that is used to set the tooltip text that is displayed in the column when
tooltips are active.
A
String
argument is the tooltip text that is displayed in every cell in the column.
An argument that is an
Array
should contain the
String
that is supposed to be displayed as the tooltip text in each row in the column.
-
type
This value cannot be set, only retrieved using
GET_COLUMN_FIELD.
-
values
Takes an
Array
argument whose elements are new values for the row elements in the specified
column.
-
visible
Takes an
int
argument which will make the column invisible when zero and restore the
column's visibility otherwise.
Internally, making the column invisible means setting the column's minimum and
maximum width values to zero and restoring visibility means setting
the minimum, maximum and preferred width values to their
values in effect when the column was made invisible.
-
width
Takes either a
Number
argument, which is used to set the width of the column, to the extent possible,
based on 72 units per inch, or the argument can be a
Dictionary.
In this latter case, values identified by the names
maximum,
minimum,
or
width
can be used to set, as best as possible, the maximum, minimum and desired width of the
column.
When the maximum and minimum values are both zero, the column will exist, but it
will not be visible, but setting the
visible
column field is the preferred way to control column visibility.
-
SET_COLUMN_SELECTION
clears and then
sets the selection status of the specified columns without
affecting the selection status of any other columns (unless
multiplemode
is set to
SINGLE_SELECTION).
At least one
int
argument specifying a column to be affected must be present.
If a second
int
argument column specification is present, the two arguments define an
inclusive range of columns to be affected.
A trailing
String
argument determines the selection mode
and can take the values "on", "off" or "toggle",
although "toggle" is equivalent to "on" since the selection is always
cleared before the specified mode is applied.
When no string argument is present, the selection mode is "on".
For column selection to occur, column selection needs to be activated (see the
COLUMN_SELECTION
action).
-
SET_EDITOR_BOX
Given an
int
argument indicating a column number within the values matrix and a
JComboBox,
this action assigns the
JComboBox
to the specified column for selecting and editing values in that
column.
Assigning
NULL
reverts the editor to the default
JTextField.
-
SET_FIELD
This action sets the value of a cell within the table by accepting
two
int
arguments representing the row and column, respectively, of the cell
in the values matrix and a value to be assigned.
The value may be expressed as a
String
having a format appropriate to the column type and as specified by the
inputFormat
column
attribute
or an object having a type appropriate to the column type.
Numeric object may have a unformatted numeric value or a value corresponding to
that specified by the
inputFormat
column
attribute.
Appropriate object value types for given column types are as follows:
-
BOOLEAN_TYPE
takes an
int
object.
-
DATE_TYPE
takes a
double
object
representing a time value (i.e., seconds since January 1, 1970).
-
DOUBLE_TYPE
takes a
double
object.
-
HISTOGRAM_TYPE
takes a
double
object.
-
ICON_TYPE
takes an
Image
object.
-
INTEGER_TYPE
takes an
int
object.
-
MONEY_TYPE
takes a
double
object.
-
PERCENT_TYPE
takes a
double
object where, for example, 1% is expressed as 0.01.
-
STRING_TYPE
takes a
String
object.
-
TEXT_TYPE
also takes a
String
object, but can display multiple lines with word wrap because it uses a
JTextPane
to handle display.
The
format
attribute can be used to specify
html,
plain
or
rtf
parsing of the supplied
String.
The
inputformat
attribute can be used to define a line-break character (for plain text). By default, a caret
(^)
can be used to force a line break in the supplied text.
-
TIMER_TYPE
takes a
double
object expressing a length of time in seconds.
-
SET_FIND_MARKER
Positions the find marker at the specified cell as indicated by a pair of
int
arguments which indicate the row and column of a cell within the current view.
If the supplied values indicated a valid cell, the cell is highlighted and
the find marker is position at that cell so a subsequent calls to
findNextMatch
will begin from that cell.
If the supplied values do not indicate a valid cell, the
current find marker, if any, is cleared from the table and a subsequent
search request will start from the beginning of the table.
-
SET_ROW_SELECTION
clears and
sets the selection status of the specified rows without
affecting the selection status of any other rows (unless
multiplemode
is set to
SINGLE_SELECTION).
At least one
int
argument specifying a row to be affected must be present.
If a second
int
argument row specification is present, the two arguments define an
inclusive range of rows to be affected.
A trailing
String
argument determines the selection mode
and can take the values "on", "off" or "toggle",
although "toggle" is equivalent to "on" since the selection is always
cleared before the specified mode is applied.
When no string argument is present, the selection mode is "on".
For row selection to occur, row selection needs to be activated (see the
ROW_SELECTION
action).
-
SET_TYPE_FIELD
Given an
int
argument indicating a field type, a
String
argument that is either
alignment
or
attributes
and an appropriate value,
this action will set the alignment or attribute characteristics of
the specified field type, which will affect all columns sharing the
same field type that do not specifically override those values.
Field types are:
BOOLEAN_TYPE,
DATE_TYPE,
DOUBLE_TYPE,
HISTORGRAM_TYPE,
ICON_TYPE,
INTEGER_TYPE,
MONEY_TYPE,
PERCENT_TYPE,
STRING_TYPE
TEXT_TYPE
and
TIMER_TYPE.
The
alignment
and
attributes
are set as follows:
-
alignment
determines column cell alignment and
is set by means of one of the keyword constants:
LEFT,
RIGHT
or
CENTER.
-
attributes
determines how numeric fields are displayed and is
set using a
Dictionary
containing one or more attribute identifiers and associated values.
Attributes are set in the same manner as described in the
SET_COLUMN_FIELD
action.
-
SYNCROWVIEWS
will synchronize the table view with the underlying data matrix or
vice versa.
When a
int
argument is provided, then a zero value (the default) indicates that
the underlying data matrix should be changed to reflect the current
table view, otherwise
the table view will be changed to reflect the underlying data matrix.
-
TABLE_JOIN
will extract and return the contents of all or part of the table joined
together either as a
String
or as an
Array.
This action takes from zero to six additional arguments.
The six arguments, in the order in which they should appear, are:
-
an indicator for the columns to be joined.
It may be an
int
indicating a specific column, an
Array
of integers indicating various columns, or a
NULL
indicating all columns.
The default value is
NULL,
meaning the entire table.
-
an indicator of whether
view-mode
or
value-mode
should be used when
interpreting the columns requested by the first argument, meaning the columns
numbers are with respect to the way the table is displayed
(view-mode)
or the way the underlying data is arranged
(value-mode).
A non-zero
int
invokes
view-mode,
while zero invokes
value-mode.
The default is
view-mode.
-
an indicator of whether
text-mode,
namely a delimited
String,
or
values-mode,
namely an
Array
of
Array
elements, should be used when constructing the output.
A non-zero
int
invokes
text-mode,
while zero invokes
values-mode.
The default is
text-mode.
-
an indicator of whether
row-mode,
column-mode
or
table-mode
should be used when constructing the returned result.
A positive
int
invokes
row-mode,
a negative
int
invokes
column-mode
and zero invokes
table-mode.
The precise meaning of these modes depends on whether
text-mode
or
values-mode
is being used.
In
text-mode,
row-mode
means an
Array
is constructed containing an element for each row and each element is a single
String
containing the specified column elements separated by the
outputfilter
field delimiter.
In
values-mode,
row-mode
means an
Array
is constructed containing an element for each row and each element is an
Array
containing an element for each value in the specified columns within that row.
In
text-mode,
column-mode
means an
Array
is constructed containing an element for each specified column and
each element is a single
String
containing all the row elements in that column separated by the
outputfilter
record delimiter.
In
values-mode,
column-mode
means an
Array
is constructed containing an element for each specified column and each element is an
Array
containing an element for each row value within that column.
In
text-mode,
table-mode
means a single
String
is constructed containing, for each row in the table,
an element for each specified column delimited by the
outputfilter
field delimiter and terminated by the
outputfilter
record delimiter.
In
values-mode,
table-mode
means a single
Array
is constructed containing elements corresponding to all the cells within
the specified columns and all the rows of the table. The cells are entered
into the array in left-to-right, top-to-bottom order.
The default is
table-mode.
-
an
int
which when zero has no effect (the default behavior), but otherwise
forces cell elements to be converted to text values regardless of the value of the third
argument described above and without affecting the output behavior described for the preceding
argument.
Moreover, if the integer is positive, then the text is formatted to match the format used when
displaying the cell values in the table on screen.
-
a
String
or an
Array
of at most two
String
objects that determine the column-wise cell delimiter and the
row delimiter when writing performing the
TABLE_JOIN
operation.
The default is to use the current value of the table's
outputfilter
field.
If the column-wise cell delimiter is explicitly set to a comma by this argument, then the output
format will be comma-separated values format.
-
TABLE_RESORT
Takes no arguments and simply resorts the table using the current
sort criteria, if any. This action is useful
after a field value has been changed either programmatically or through
interactive editing.
-
TABLE_SORT
Takes zero or one arguments for specify a row ordering of the table data.
The one argument can be an
int
for specifying a single column upon which to base the row-ordering,
an
Array
of integers
for specifying several columns to be used for ordering the
rows or
NULL,
which results in an action equivalent to the
TABLE_RESORT
action and is also the default behavior.
The integers specify the sort by referring the first column as 1, the second
as 2 and so on. Note that in all other numbered references to columns, the
numbering starts at 0.
This difference is needed here since the columns need to be referred to either
by a positive integer, indicating the sort using that column should be in
ascending order, or by a negative integer, indicating the sort using that
column should be in descending order.
| | afterSelect([int row, int column]) |
A
Function
that is called, if it is not
NULL,
whenever the current selection changes.
If the declaration of
afterSelect
includes the optional
row
and
column
arguments, then each generated call includes location in the values matrix of the
currently selected cell.
| | allowEdit([int row, int column] [, Object event]) |
A
Function
that is called, if it is not
NULL,
before the contents of a cell can be changed by editing or the
SET_FIELD
action and should return zero (i.e.,
FALSE)
if changes are not allowed.
If the declaration of
allowEdit
includes the optional
row
and
column
arguments, then each generated call includes location in the values matrix of the targeted cell.
In addition, if the declaration includes the optional
event
argument then the event that triggered the call, if there was one, will also be included in
the generated call.
| | altalignment |
An
int
that controls the default positioning of the text in the header.
The value should be
LEFT,
CENTER,
or
RIGHT,
which are all defined in
yoix.swing.
Reading returns the current alignment.
Writing immediately repaints the text using the new alignment,
assuming it is not superceded by a column-specific value.
| | altbackground |
The
Color
or
Array
of colors that is used, by default, to paint the header background.
When the value is an
Array,
it can contain up to three elements, which would be the color
used normally, the color used when the column is sorted in descending
order and the color when the column is used for ascending sorting.
When set to
NULL,
the single table background color is used.
Reading returns a snapshot of the current colors.
Writing immediately repaints the header with the new colors,
assuming that it is not superceded by column-specific values.
| | altfont |
The
Font,
or font name if it is a
String,
used, by default, to paint the text strings displayed by the table header.
Reading returns a snapshot of the current font.
Writing immediately repaints the text strings displayed in the header
in the new font,
assuming it is not superceded by a column-specific value.
| | altforeground |
The
Color
or
Array
of colors that is used, by default, to paint the header foreground, which
generally means the font color.
When the value is an
Array,
it can contain up to three elements, which would be the color
used normally, the color used when the column is sorted in descending
order and the color when the column is sorted in ascending sorting.
When set to
NULL,
the single table foreground color is used.
Reading returns a snapshot of the current colors.
Writing immediately repaints the header with the new colors,
assuming that it is not superceded by column-specific values.
| | altgridcolor |
The
Color
that is used to paint the lines dividing the table header cells when no
invocationSelection
event listener is associated with the table (adding such as listener changes the
column headers into button like elements, so no header grid is present in that case).
When this value is
NULL,
the table grid color is used, unless that value, too, is
NULL,
in which case the header foreground color is used.
Reading returns a snapshot of the current color.
Writing immediately repaints the grid in the new color.
| | alttooltiptext |
A
String
or
Array
of strings that is used for the header tooltip text.
A single string value serves as the tooltip for all column headers.
For an array of strings, the first string is the header tooltip for the first column,
the second string for the second column and string N for column N and all subsequent columns.
If
tooltips
is
TRUE,
but this field is not assigned, then the header label serves as the tooltip text,
which can be useful for seeing the label text even when the column is not wide enough
to accommodate it.
A
NULL
string value suppress tooltip display for the corresponding column or columns.
See also
tooltips.
| | background |
The
Color
that is used to paint the background of the table by default.
Reading returns a snapshot of the current color.
Writing immediately changes the background to the new color,
assuming that it is not superceded by a column-specific value or
cellcolors.
Storing
NULL
in
background
is special and means use the background of the nearest component
that contains the table and was assigned a background color other than
NULL;
if no component qualifies the table uses
VM.screen.background.
| | border |
An
Object
that should be a
Border,
Insets,
Number,
or
String
that describes the border that is drawn around this table.
A
NULL
value, which is the default, means no border.
A
border
that is an
Insets
or
Number
is an easy way to describe margins
(i.e., an
EmptyBorder),
in units of 72 dots per inch, that are left around the sides of this table.
A
border
that is a
String
is a quick way to surround this table with a border that uses the
String
as its title.
Reading returns a snapshot of the current border.
Writing immediately sets the table's border to the new value.
| | bordercolor |
| | cellcolors |
An
Array
with two elements that is used to determine the default table cell coloring,
effectively overriding the table's background color within the cells.
The first element addresses cell background coloring, while the second element
addresses cell foreground color.
Each element can be a
Color
or an
Array
of colors.
When an
Array
is used, its first element applies to the first row, the second to the
second row, and so on.
If there are more rows than array elements, the coloring cycles back to the
first element in the array and proceeds from there.
See also
getArrayBands
in yoix.util.
| | clickcount |
An
int
that determines the number of mouse clicks required to activate cell editing.
Reading returns the current click count.
Writing cancels editing, if a cell is being edited, and
immediately sets the table's click count to the new value.
| | columns |
An
Array
of
JTableColumn
objects representing the table columns.
Reading returns an array of copies of the current column objects.
Writing immediately sets the table's columns to the new values.
| | cursor |
An
Object
that should be an
int,
Image,
or
String
that selects the cursor shown when the pointer is over the table.
A
cursor
that is an
int
should be one of the cursors defined in the
yoix.awt.Cursor
dictionary.
A
cursor
that is an
Image
can describe the cursor using its
size
and
hotspot
fields and often draws it using its
paint
function.
A
cursor
that is a
String
should be the name of a cursor that is already defined in
yoix.awt.Cursor
or the name a local a file or URL that contains a GIF or JPEG image
that will be used as the cursor.
Reading returns the current cursor.
Writing immediately changes the table's cursor to the new value.
Storing
STANDARD_CURSOR
(the default) or
NULL
in
cursor
is special and means use the cursor assigned to the nearest component
that contains the table and was assigned a cursor other than
STANDARD_CURSOR;
if no component qualifies the table uses
DEFAULT_CURSOR.
| | doublebuffered |
An
int
that is
1
when the table uses double-buffering to draw itself,
0
when it does not, and starts with a default value that is
selected by Java for the table.
Reading returns the current double-buffering behavior.
Writing immediately sets the table's double-buffering behavior to the new value.
Note that double-buffering may be required when transparent components are used.
| | dragenabled |
An
int
that should be set to
1
when this tables wants to use the automatic drag handling that Swing provides
for some components, and
0
(the default)
when it does not.
Components that do not provide automatic drag handling always return
0
when their
dragenabled
field is read, so storing
1
in
dragenabled
should only be viewed as a request for a service that may not be available.
Swing components can always take complete control of their drag and drop
handling using their
transferhandler
field or special drag and drop event handlers.
| | edit |
A field that determines the editing behavior of the table.
It can take several types of values:
an
int,
which applies to the entire table, or an
Array,
whose elements apply to the rows in sequence and can be
int
values, which apply to entire rows, or
Array
objects, whose elements, which are
int
values, apply to individual cells within the rows.
An
int
value of
1
turns editing on and
0
turns editing off.
Reading returns the current editing configuration.
Writing immediately changes the tables's editing configuration to the new value.
| | editbackground |
A
Color
used as the edit background color.
| | editforeground |
A
Color
used as the edit foreground color, usually the font color.
| | enabled |
An
Object
that is
1
when the table can respond to user input,
0
when it can not respond, and
NULL
(the default)
when the table inherits the value from the nearest lightweight container,
like a
JPanel,
that contains the table and has its
enabled
field set to something other than
NULL.
The top-level application window that contains the table always gets the
final say, so disabling that window always disables the table.
Reading returns the current state.
Writing immediately sets the table's state to the new value.
| | extent |
A read-only
Dimension
that represents the size of the table scroller's viewport.
| | findNextMatch(String pattern, int mode, int ignorecase, int bycols, int forward) |
A built-in that searches the table for the supplied
String.
The type of search is specified by
mode,
where a negative value indicates shell pattern searching (sometimes referred to
as a GLOB pattern), a zero indicates a pure text search and a positive value
indicates a regular expression search.
Text search is the default.
Case is ignored in the search when
ignorecase
is non-zero.
Case is ignored by default.
The search proceeds row-wise unless
bycols
in non-zero in which case the search proceeds column-wise.
Row-wise is the default.
The direction of the search is forward when
forward
is non-zero, backwards otherwise.
The default is forward.
When a match occurs, the cell containing the match is highlighted by
reversing the foreground and background cell colors and the
function returns a string representation of the value contained in the cell.
Otherwise,
NULL
is returned and the selection is cleared.
Searches proceed from the currently highlighted cell or from the beginning of
the table if no cell is highlighted.
This highlight marker, and thus the subsequent search,
can be interactively positioned by depressing the shift and control keys
(SHIFT-CTRL)
together and then, with the keys still depressed, pressing and releasing mouse button 1 in a cell.
When such an action occurs on a previously highlighted cell, the highlight is
cleared.
For programmatic access to the marker, use the
GET_FIND_MARKER
and
SET_FIND_MARKER
options of the
action
built-in.
The find highlight marker is independent of the standard
table selection highlighting mechanism.
| | focusable |
An
int
that is non-zero (the default)
when the table can accept the keyboard focus and zero
when it can not.
Reading returns the table's current focusable state.
Writing immediately changes the table's focusable state to the new value,
which means the focus is automatically transferred if the new value is zero
and the table is the current focus owner.
| | focusowner |
A read-only
int
that is non-zero when the table has the focus.
| | font |
The
Font,
or font name if it is a
String,
used by default to render the characters stored in the table cells.
Reading returns a snapshot of the current font.
Writing immediately repaints the text in the new font.
| | foreground |
The
Color
that is used by default to paint the characters stored in the table cells.
Reading returns a snapshot of the current color.
Writing immediately repaints the text in the new color,
assuming it is not superceded by a column-specific value.
Storing
NULL
in
foreground
is special and means use the foreground of the nearest component
that contains the table and was assigned a foreground color other than
NULL;
if no component qualifies the table uses
VM.screen.foreground.
| | gridcolor |
The
Color
that is used to paint the lines dividing the table cells.
Reading returns a snapshot of the current color.
Writing immediately repaints the grid in the new color.
| | gridsize |
A
Dimension
object which determines the size of the region buffering the cell content
from the grid lines.
The
width
applies to the horizontal spacing and the
height
applies to the vertical spacing.
Various table sizing constraints may affect the actual spacing assigned.
Reading returns a snapshot of the current spacing.
Writing immediately respaces the grid.
| | headericons |
An
Image,
Array
of containing any combination of images, arrays of images or
NULLs.
When the value is a single image, it is used as the header icon for all columns
regardless of the sort state of the columns.
When the value is an array, then the first element is the value for the header icon
of the first column, the second for the second and so on with the last value also
serving as the header icon value for any remaining table columns.
Each element in such an array affects the corresponding column as follows:
-
a
NULL
value indicates no icon is to be used regardless of sort state,
-
a single image or the first image in an array of images, when its size is less than three,
acts as the header icon regardless of sort state,
-
for an array of images with size greater than or equal to three, then the first image
in that array is the header icon when the column is unsorted, the second image is the
header icon when the column is sorted in increasing order and the third image is the
header icon when the column is sorted in decreasing order.
Writing immediately changes the header icons, while reading provides a current snapshot.
| | headers |
An
Array,
String
or
int
value that is used to set the column headers.
Assigning a non-zero
int
value activates default column headers, sequential upper-case alphabetics
A,
B,
C
and so on.
Assigning a zero
int
value removes column headers completely.
An
Array
value should contain only
String
values.
When assigning a
String
value, it will be parsed internally into an array of strings based on the
inputfilter
value.
In either case, the number of elements in the array will will determine the
number of columns in the table meaning that columns will be added or deleted
as needed to match the number of header elements.
Reading returns a snapshot of the current header array.
Writing immediately sets the column headers to the new value.
| | inputfilter |
An
Object,
that must be a
String
or
Array,
that controls how strings stored in the
text
field are separated into the columns that are loaded in the table.
The default inputfilter assumes each row ends at the next newline
and that columns are separated by the vertical bar
(|)
character.
Note that newlines are stripped from the input text before the text is placed in the table.
Reading returns the current inputfilter.
Writing changes the filter that is used the next time the table is loaded.
When inputfilter is a string, each line in
text
corresponds to a row in the table and the supplied string in the inputfilter
qualifies as a column separator.
An inputfilter that is an
Array
must be arranged in triples that consist of a prefix that is a
String,
a column number that is an
int,
and a simple character translator that is a
String
or
NULL.
Each line in
text
is compared to the prefix in each triple.
When there is a match the prefix is stripped from the line and the remainder, after
any translation, as described below, is taken as the
value for the column as specified by the second element in the triple.
Translation involves replacing any character matching a character found
at an odd position in the translation string, namely positions 1, 3, 5 and so on,
by the character following it in the translation string.
The translation affects all occurences of a match in the input.
With this form of
inputfilter,
the row delimiter is either an empty line of input or when the field corresponding to the
column with the highest ordinal value in the
inputfilter
specification.
For the column specification, column numbering begins with the value 1 rather than 0.
Mulitple row delimiters occurring in succession are compressed to a single occurence.
| | layer |
An
int,
often a small number between 0 and 99,
that identifies the depth of this table when it is added to a
JLayeredPane
or
JDesktopPane.
Components assigned to lower numbered layers are drawn before
the components in higher numbered layers.
Writing immediately changes the table's layer, which usually means the
JLayeredPane
or
JDesktopPane
that contains the table will be repainted.
| | location |
A
Point
that determines the location of the table
in a coordinate system that has its origin at the upper left corner
of the container closest to the table (in the component hierarchy)
that actually contains it, positive x to the right, positive y down,
and a resolution of 72 dots per inch.
Reading returns a snapshot of the current location.
Writing is allowed, but layout managers usually get the final say, so setting
location
should be viewed as a request that may not be honored.
| | modelToView(int index, String mode) |
A built-in that converts an
index
in the values matrix (data model)
to the corresponding index in the visible table
(table view).
The
index
refers to a row or a column based on whether the
mode
string begins with "r" or "c", respectively, regardless of case.
The index is silently constrained to be with the proper range based on the
current size of the table.
If there is no data in the table, a negative value is returned.
| | multiplemode |
An
int
that is
MULTIPLE_INTERVAL_SELECTION
when more than one item can be selected.
Any other value, including in particular
SINGLE_SELECTION,
means that only one item can be selected at a time.
Reading returns the current mode.
Writing immediately sets a new mode and deselects any currently
selected elements in the table.
| | nextfocus |
An
Object
that identifies the component that receives the focus after this table
when the focus traverses from one component to the next
(usually by means of the keyboard
TAB
character).
When
nextfocus
is a
String
it is assumed to be the tag associated with the target component,
which must belong to the same top-level container (e.g., the same
JFrame)
as this table.
A
NULL
value means the component that gets the focus after this table will be
selected by Java's default focus traversal policy.
Reading returns the value last stored or
NULL
if the value was a
String
that did not reference a component.
Writing immediately changes the component that gets the focus after this table.
| | opaque |
An
Object
that is
1
when the table is opaque,
0
when it is transparent, and
NULL
(the default)
when the table inherits the value from the nearest component that
contains the table and has its
opaque
field set to something other than
NULL.
| | origin |
A read-only
Point
that is the coordinate of the table in the upper-left corner of the
table scroller's viewport
in a coordinate system that has its origin at the upper left corner of the table
with positive x to the right, positive y down
and a resolution of 72 dots per inch.
| | outputfilter |
An
Array
of at most two
String
objects that determine the column-wise cell delimiter and the
row delimiter when writing the table contents as a text string.
Reading returns the current values.
Writing immediately sets the delimiters to the new values.
Setting the entire field or one of the delimiters to
NULL
restores the appropriate default values.
| | popup |
A
JPopupMenu
that is associated with the table.
Reading returns the current popup menu.
Writing immediately shows the popup menu at the point in the table's coordinate
system specified by the popup menu's
location
field, assuming of course that the table is showing on the screen.
Storing
TRUE
in the popup menu's
visible
field, which was added in release 1.2.0, is an easy way to show the
popup menu that currently belongs to the table.
| | preferredsize |
A
Dimension
that is used by layout managers when they need to know the table's
preferred size in units of 72 dots per inch.
A
NULL
value means the table has no preference.
A non-positive height or width is allowed and simply means the table
has no preference for that dimension.
Reading returns the current preferred size.
Writing changes the preferred size and immediately notifies
root.layoutmanager,
which means the components contained in
root
may be repositioned and resized.
| | reorder |
An
int
that is
1
when the columns can be reordered by mouse dragging the column header and
0
otherwise.
Reading returns the reorder state.
Writing immediately shows the reorder state to the new value.
| | requestfocus |
An
int
that can be used to request or transfer the keyboard focus.
Storing a non-zero value in
requestfocus
tries to get the focus.
Storing
0
tries to transfer the focus.
Reading
requestfocus
does not currently return any useful information.
| | resize |
An
int
that is
1
when the columns can be resize by mouse dragging the column header boundary
and
0
otherwise.
Reading returns the resize state.
Writing immediately shows the resize state to the new value.
| | resizemode |
An
int
that sets the automatic resizing mode for the table columns.
Values and their resulting effect are:
-
AUTO_RESIZE_ALL_COLUMNS,
which proportionately resize all columns during a resize operation.
-
AUTO_RESIZE_LAST_COLUMN,
which applies adjustments to the last column only during a resize operation.
-
AUTO_RESIZE_NEXT_COLUMN,
which adjust the grows or shrinks the next column in the opposite way
that the current column is being resized,
-
AUTO_RESIZE_OFF,
which does not allow automatic column resizing and is recommended when horizontal scrolling is desired,
-
AUTO_RESIZE_SUBSEQUENT_COLUMNS,
which grows or shrinks all subsequent columns in the opposite way that
the current column is being resized.
| | root |
An
Object
that is automatically updated by the interpreter's layout machinery
so it is always the top-level object that contains the table.
For example, put a table in a panel and
root
will be set to that panel;
add the panel to a frame and the table's
root
field will be set to that frame.
A table's event handlers can use
root
when they need to interact with the other components in the container.
| | rowheightadjustment |
A
double
that is added to the default row height.
The value is screen units of 72 per inch.
A negative value has a special meaning.
It indicates that the minimum necessary should be added to the row height so
that text is not truncated height-wise when a cell is in (text) edit mode.
| | rows |
An
int
that specifies the number of rows in a new table.
Changing
rows
after a table has been created has no effect and eventually may
trigger an
invalidaccess
error.
Normally the number of rows in a table is determined by the data assigned
to the table.
| | scroll |
An
int
that controls how scrollbars are added to a new table.
The value should normally be one of
NONE,
HORIZONTAL,
VERTICAL,
BOTH,
or
AS_NEEDED
(the default), which are all defined in
yoix.swing.
Fancier controls described in the
JScrollPane
reference page are allowed here, but in practice they are rarely needed.
In addition you can explicitly set
scroll
to zero to permanently disable scrolling in this table.
Note that it is recommended that the
resizemode
be set to
AUTO_RESIZE_OFF
when horizontal scrolling is desired.
| | selectionbackground |
The
Color
that is used to paint the background of selected cells in the table.
Reading returns a snapshot of the current color.
Writing immediately changes the color to the new color,
assuming that it is not superceded by a column-specific value.
| | selectionforeground |
The
Color
that is used to paint the foreground, usually the text,
of selected cells in the table.
Reading returns a snapshot of the current color.
Writing immediately changes the color to the new color,
assuming that it is not superceded by a column-specific value.
| | showing |
A read-only
int
that is non-zero when the table is showing on the screen.
| | size |
A
Dimension
object that determines the preferred size of the data region of the table.
Layout managers usually get the final say, so setting
size
should be viewed as a request that will not always be honored.
| | sortmap |
An
Array
of
ints
that can be used to force one column to be sorted by the contents of a different column
that may or may not be visible.
Elements in the array are arranged in pairs and are assumed to be column numbers in the
values matrix with first element being the index of the column that was supposed to be sorted
and the second element being the index of the column that is actually sorted.
| | tag |
A
String
used to identify the table that is either supplied when
the table is declared, or automatically generated otherwise.
Add a table to a container, like a
JFrame
or
JPanel,
and the interpreter's layout machinery updates the
root
field so it points at the top-level container and then adds the table, as
tag,
to the
root.components
dictionary.
| | text |
A
String
representation of the table data.
When reading, elements are in left-to-right, top-to-bottom order with the
first element of the
outputfilter
separating column elements and the second element separating each row.
When writing, elements are in left-to-right, top-to-bottom order with the
inputfilter
separating column elements on input and each row on
a separate line.
If there are fewer data columns supplied than there are header columns, the
extra columns will be left blank.
If there are more data columns supplied than there are header columns, the
extra columns will be stored as string values and extra
STRING_TYPE
columns will be created as needed with alphabetic header labels created in increasing
order.
If there is no header, then the number of table columns will grow or
shrink as needed to match the number of data columns supplied.
Reading gives a snapshot of the current contents of the table as a text
representation.
Writing immediately updates the contents of the table with the new values.
representation.
| | tooltips |
An
int
that is
1
when tooltips are active and
0
otherwise.
It is a convenient way to turn tooltips on and off without needing to
reset the value of
tooltiptext.
Reading returns a snapshot of the state.
Writing immediately changes the tooltip mode to the new value.
| | tooltiptext |
A
String,
Array
of strings or
Array
of string arrays
that is displayed in a tightly sized pop-up window that
appears near the cursor whenever the cursor lingers over the table.
If a single
String
is supplied, it applies to the whole table.
If an
Array
of strings is supplied, then the first element applies to the first
row, the second element to the second row and so on. The tips do
not cycle, however.
If any of the elements is an
Array
rather than a
String,
then all elements only apply to specific cells.
In particular, strings within an array that is within an array apply
sequentially to the columns within the row to which the enclosing array
applies.
Furthermore, strings within an array that is not enclosed in another array
applies only to the first column of the corresponding row, namely it is
equivalent to having a string as the single element in an array enclosed
within an array.
Setting
tooltiptext
to
NULL
(the default)
disables the tooltip mechanism, otherwise the mechanism is enabled.
See also
tooltips
for a way to enable or disable the mechanism without changing the
value of
tooltiptext.
Reading returns the current tooltip text.
Writing immediately sets the new tooltip text.
| | transferhandler |
An
Object
that should be a
TransferHandler
or
String
that determines how the table handles data transfer operations
like drag and drop.
A value that is a
String
but not
""
means the field named by the
String
should be used as the source and sink of the data that is transferred by
the table.
The result is the same as assigning the
String
to the
property
field in a
TransferHandler
and then assigning that
TransferHandler
to
transferhandler.
The empty
String
""
is special and refers to the
TransferHandler
that Swing uses for automatic drag handling, if there is one.
Swing components that provide automatic drag handling start out with a
transferhandler
field that is not
NULL,
but the automatic drag handling is not enabled until
1
is stored in
dragenabled.
Swing components that provide their own drag and drop event handlers
currently must store
NULL
in
transferhandler
before those event handlers will start working.
| | types |
An
Array
of
int
values that describe the data types of the columns.
There is one value for each table column.
The values correspond to the constants:
BOOLEAN_TYPE,
DATE_TYPE,
DOUBLE_TYPE,
HISTOGRAM_TYPE,
ICON_TYPE,
INTEGER_TYPE,
MONEY_TYPE,
PERCENT_TYPE,
STRING_TYPE
TEXT_TYPE
and
TIMER_TYPE.
This field is effectively read-only as attempting to re-assign a type
after the table is created is results in a
typecheck
error.
| | useedithighlight |
Normally when an editable cell has the focus it is displayed both with a highlighted
border and highlighted foreground / background colors.
That is the situation when this
int
field is non-zero.
However, when this field is set to zero, only the border highlight is displayed.
| | validator |
A user-defined
Function
that is called after a cell is edited.
It is supplied with five arguments.
The first three arguments are
int
values and they are the row, the column and the
type of the edited element, respectively.
The last two arguments are
Object
values that provide the post-edited and pre-edited values, respectively,
of the cell.
If the function returns true, the edit is accepted. If it returns false,
the edit is considered an error and needs to be corrected or canceled.
| | values |
An
Array
containing arrays, each representing a table row, whose elements are
objects representing table cell values.
As a convenience,
values
will also accept a
String
value, in which case it behaves the same as when
text
is assigned a
String.
If needed,
STRING_TYPE
columns will be created to accomodate the supplied data.
Reading returns a snapshot of the current table data values.
Writing immediately replaces the table data values with the array element
values.
| | viewToModel(int index, String mode) |
A built-in that converts an
index
in the
visible table (table view)
to the corresponding index in the
values matrix (data model).
The
index
refers to a row or a column based on whether the
mode
string begins with "r" or "c", respectively, regardless of case.
The index is silently constrained to be with the proper range based on the
current size of the table.
If there is no data in the table, a negative value is returned.
| | viewport |
A read-only
Rectangle
combining the information provided by the
origin
and
extent
fields.
| | viewrowcount |
A read-only
int
that indicates how many table rows can be viewed without the need for scrolling.
This number can be greater than the current number of rows in the table.
The value changes when the table's scrollpane is resized.
If an actual size is unavailable, the preferred size information is used.
| | visible |
An
int
that is
1
when the data portion of the table is visible and
0
otherwise.
Reading returns the current visibility.
Writing changes the visibility to the new value.
| | visiblewidth |
A read-only
int
that gives the current number of visible columns in the table, where visibility
refers to being displayed at all versus being current in the scroll pane.
| | width |
A read-only
int
that gives the current number of columns in the table.
|
Several permanent fields have not been documented and should not be
used in Yoix applications.
Event handlers are functions that normally added to a table when it is
declared.
The handlers that work with tables are listed below;
the names should be familiar if you have done some Java programming with
the exception of
invocationAction,
invocationChange,
invocationEdit,
invocationEditImport,
invocationEditKey
and
invocationSelection.
These handlers are called when, respectively, a mouse click occurs on a
table header, a cell is edited and a mouse click occurs in a table cell.
The
actionPerformed
and
itemStateChanged
event handlers are only for menus.
| |
| Event Handlers: |
actionPerformed,
componentHidden,
componentMoved,
componentResized,
componentShown,
dragDropEnd,
dragEnter,
dragExit,
dragGestureRecognized,
dragMouseMoved,
dragOver,
drop,
dropActionChanged,
focusGained,
focusLost,
invocationAction,
invocationChange,
invocationEdit,
invocationEditImport,
invocationEditKey,
invocationRun,
invocationSelection,
itemStateChanged,
keyPressed,
keyReleased,
keyTyped,
mouseClicked,
mouseDragged,
mouseEntered,
mouseExited,
mouseMoved,
mousePressed,
mouseReleased,
mouseWheelMoved
| | |
| Example: |
The program,
import yoix.*.*;
String census = "\
Total population|281421906|1.0\n\
Male|138053563|.491\n\
Female|143368343|.509\n\
";
JFrame jf = {
Dimension size = NULL;
int visible = 1;
Array layout = {
new JTable {
Color gridcolor = Color.red;
String text = census;
Array headers = { "Subject", "Number", "Percent" };
Array types = { STRING_TYPE, INTEGER_TYPE, PERCENT_TYPE };
Dimension preferredsize = { int width = 360; };
},
};
};
displays a brief
table of census data showing both count and percentage columns.
More control over the table is possible by explicitly configuring
the individual columns.
In the program below, the same data is displayed using
JTableColumn
objects to configure various column options such as width and background
color.
import yoix.*.*;
String census = "\
Total population|281421906|1.0\n\
Male|138053563|.491\n\
Female|143368343|.509\n\
";
JFrame jf = {
Dimension size = NULL;
int visible = 1;
Array layout = {
new JTable {
Color gridcolor = Color.red;
Color background = Color.white;
String text = census;
Array columns = {
new JTableColumn {
String header = "Subject";
int width = 144;
int type = STRING_TYPE;
},
new JTableColumn {
String header = "Number";
int width = 96;
int type = INTEGER_TYPE;
Color background = Color.gray;
},
new JTableColumn {
String header = "Percent";
int width = 72;
int type = PERCENT_TYPE;
Dictionary attributes = {
String format = "#,##0.00%";
};
},
};
},
};
};
| | |
| See Also: |
appendText,
BevelBorder,
Border,
EmptyBorder,
EtchedBorder,
invokeLater,
JButton,
JCanvas,
JCheckBox,
JCheckBoxMenuItem,
JChoice,
JColorChooser,
JComboBox,
JDesktopPane,
JDialog,
JFileChooser,
JFileDialog,
JFrame,
JInternalFrame,
JLabel,
JLayeredPane,
JList,
JMenu,
JMenuBar,
JMenuItem,
JPanel,
JPasswordField,
JPopupMenu,
JProgressBar,
JRadioButton,
JRadioButtonMenuItem,
JScrollBar,
JScrollPane,
JSeparator,
JSlider,
JSplitPane,
JTabbedPane,
JTableColumn,
JTextArea,
JTextCanvas,
JTextField,
JTextPane,
JTextTerm,
JToggleButton,
JToolBar,
JTree,
JWindow,
LineBorder,
MatteBorder,
postEvent,
SoftBevelBorder,
TransferHandler
|
|