|
SilverStream Application Server 3.5 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--javax.swing.JTable
|
+--com.sssw.rt.jform.AgcJTable
A lightweight component that displays rows and columns of data. It's
easy to set up a table with data by retrieving data with an AgcData
control and putting the data in the table with AgcJTable.loadFromRowCursor( AgiRowCursor, int[], int[], int).
The table can be bound to a database column. When you load the table
data with loadFromRowCursor(), you specify a value column,
which provides the
storage values for the table. The value column doesn't have to be
displayed. When any cell in a
particular row is selected, the data in the value column
is passed to the database when you call
updateRows() the form.
To build a table model that that binds every table column to a database column
and is updatable,
see AgoRowCursorTableModel.
In addition to being data-bound, the control is a data-loaded control
in which loadFromRowCursor() provides data from a database table or other data source.
You can use methods of AgiRowSetManager to navigate the data.
However, changes to the table data do not affect the underlying data; therefore,
calling updateRows() for the control is not allowed. If you call it,
updateRows() throws AgoUnsupportedOperationException.
AgcJTable uses a data model. You can call the inherited method JTable.getModel() to get the model and manipulate the data.
You can enable editing by calling AgcJTable.setEditable(boolean). You can
call methods inherited from JTable to customize the table
appearance and behavior.
For an example of using a table control, see Using the Swing Table Control in the online book Application Techniques.
| Inner classes inherited from class javax.swing.JTable |
JTable.AccessibleJTable |
| Inner classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
| Fields inherited from class javax.swing.JComponent |
accessibleContext,
listenerList,
TOOL_TIP_TEXT_KEY,
ui,
UNDEFINED_CONDITION,
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
WHEN_FOCUSED,
WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
LEFT_ALIGNMENT,
RIGHT_ALIGNMENT,
TOP_ALIGNMENT |
| Constructor Summary | |
AgcJTable()
Constructs a default table control which is initialized with a default data model, a default column model, and a default selection model. |
|
AgcJTable(int numRows,
int numColumns)
Constructs a table control with the specified number of rows and columns filled with empty cells using the DefaultTableModel. |
|
AgcJTable(Object[][] rowData,
Object[] columnNames)
Constructs a table control that displays the specified data values with the specified column names. |
|
AgcJTable(TableModel dm)
Constructs a table control which is initialized with the specified data model, a default column model, and a default selection model. |
|
AgcJTable(TableModel dm,
TableColumnModel cm)
Constructs a table control which is initialized with the specified data model and column model, and a default selection model. |
|
AgcJTable(TableModel dm,
TableColumnModel cm,
ListSelectionModel sm)
Constructs a table control which is initialized with the specified data model, column model, and selection model. |
|
AgcJTable(Vector rowData,
Vector columnNames)
Constructs a table control that displays the specified data values with the specified column names. |
|
| Method Summary | |
Object |
getValue()
Gets the value of the selected row. |
boolean |
isEditable()
Finds out whether any cells in the table are editable. |
void |
loadFromRowCursor(AgiRowCursor rc,
int[] displaycols,
int[] editablecols,
int valuecol)
Creates rows of table data from an AgiRowCursor data source. |
void |
loadFromRowCursor(AgiRowCursor rc,
int[] displaycols,
int[] editablecols,
int valuecol,
String[] columnnames)
Creates rows of table data from an AgiRowCursor data source. |
void |
setEditable(boolean editable)
Specifies whether any cells in the table are editable. |
void |
setValue(Object value)
Selects the row where the data in the value column is equal to the specified value. |
| Methods inherited from class java.awt.Container |
add,
add,
add,
add,
add,
addContainerListener,
addImpl,
countComponents,
deliverEvent,
doLayout,
findComponentAt,
findComponentAt,
getComponent,
getComponentAt,
getComponentAt,
getComponentCount,
getComponents,
getLayout,
insets,
invalidate,
isAncestorOf,
layout,
list,
list,
locate,
minimumSize,
paintComponents,
preferredSize,
printComponents,
processContainerEvent,
processEvent,
remove,
remove,
removeAll,
removeContainerListener,
setCursor,
setLayout,
validate,
validateTree |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
| Methods implemented from interface com.sssw.rt.form.AgiHelpInfo |
getHelpInfo,
setHelpInfo |
| Methods implemented from interface com.sssw.rt.util.AgiRowSetManager |
clearRows,
haveRowsChanged,
query,
query,
refreshRows,
updateRows |
| Constructor Detail |
public AgcJTable()
public AgcJTable(int numRows,
int numColumns)
numRows - the number of rows in the tablenumColumns - the number of columns in the table
public AgcJTable(Object[][] rowData,
Object[] columnNames)
rowData - a two-dimensional array of data for the new table.
All rows must be of the same length as the columnNames array.columnNames - a 1-dimensional array containing the names of the columnsrowData is an array of arrays. For example, the value that will be in the cell at row 1,
column 5 can be obtained with the following code:
rowData[1][5];
public AgcJTable(TableModel dm)
dm - the data model for the table
public AgcJTable(TableModel dm,
TableColumnModel cm)
dm - the data model for the tablecm - the column model for the table
public AgcJTable(TableModel dm,
TableColumnModel cm,
ListSelectionModel sm)
dm - the data model for the tablecm - the column model for the tablesm - the row selection model for the table
public AgcJTable(Vector rowData,
Vector columnNames)
rowData - the data for the new table.
There must be the same number of elements in each row vector as in the columnNames array.columnNames - names of each columnrowData Vector contain the values for that row.
For example, the value that will be in the cell at row 1, column 5 can be obtained
with the following code:
((Vector)rowData.elementAt(1)).elementAt(5);
| Method Detail |
public boolean isEditable()
AgcJTable.setEditable(boolean)public void setEditable(boolean editable)
editable - a boolean value specifying whether any of the table is
editable. Values are:
AgcJTable.isEditable()public Object getValue()
AgcJTable.setValue(Object)public void setValue(Object value)
value - an Object whose value is meant to match a row
in the tableAgcJTable.getValue()
public void loadFromRowCursor(AgiRowCursor rc,
int[] displaycols,
int[] editablecols,
int valuecol)
throws AgoSecurityException,
AgoTransientSystemException,
AgoUnrecoverableSystemException
displaycols specify columns in the row cursor.
For editablecols and valuecol, column numbers are the columns
as they appear in the table control.rc - the AgiRowCursor object whose data you want to display in
the tabledisplaycols[] - an array of ints specifying column numbers in the
AgiRowCursor.
Those columns become the columns in the table.editablecols[] - an array of ints specifying which JTable column numbers are editablevaluecol - an int specifying the JTable column whose values will be storage values.
When the table control is bound to a database column, the storage value
of the selected row is the value updated in the database.AgcJTable.loadFromRowCursor( AgiRowCursor rc,
int[] displaycols,
int[] editablecols,
int valuecol,
String[] columnnames )AgiRowCursor,
AgcData
public void loadFromRowCursor(AgiRowCursor rc,
int[] displaycols,
int[] editablecols,
int valuecol,
String[] columnnames)
throws AgoSecurityException,
AgoTransientSystemException,
AgoUnrecoverableSystemException
displaycols specify columns in the row cursor.
For editablecols and valuecol, column numbers are the columns
as they appear in the table control.rc - the AgiRowCursor
object whose data you want to display in the tabledisplaycols[] - an array of ints specifying column numbers in the
AgiRowCursor.
Those columns become the columns in the table.editablecols[] - an array of ints specifying which JTable column numbers are editablevaluecol - an int specifying the JTable column whose values will be storage values.
When the table control is bound to a database column, the storage value
of the selected row is the value updated in the database.columnnames[] - an array of Strings specifying the column
titles. The columnnames and displaycols arrays
must be the same length.loadFromRowCursor().
int[] displaycols = { 2, 7 }; // Columns 2 and 7 of the row cursor
int[] editablecols = { 1 }; // JTable column 1 is row cursor column 7
int valuecol = 0; // JTable column 0 is row cursor column 2
String[] columnnames = { "Two", "Seven" }; // JTable column names
table.loadFromRowCursor(rc,
displaycols, editablecols, valuecol, columnnames);
This code loads the table control from the primary database table for the form.
// use first and last 2 columns from agData with 8 columns
int[] displaycols = {0, 1, 6, 7 };
// make the last 3 columns editable
int[] editablecols = {1, 2, 3};
// storage values are in the first column
int valuecol = 0;
// create some column titles from agData property names
String[] displayTitles = new String[4];
for (int i = 0; i < displaycols.length; i++) {
// the table name "Terms." is dropped from
// the property name to create the display title
displayTitles[i] = agData.getPropertyName(displaycols[i]).substring(6);
}
try{
// load the data
Table1.loadFromRowCursor( (AgiRowCursor) agData,
displaycols, editablecols, valuecol, displayTitles);
} catch (Exception e) {
System.out.println("loadFromRowCursor error: " + e);
}
AgiRowCursor,
AgcData,
AgoRowCursorTableModel
|
SilverStream Application Server 3.5 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||