com.gargoylesoftware.base.gui
public class ReflectedTableModel extends AbstractTableModel
The sample below will create a JTable with one row of data and one column per property in the Date class (Date has 10 properties in JDK1.3).
final JTable table = new JTable(); final ReflectedTableModel model = new ReflectedTableModel(Date.class); model.getRows().add( new Date() ); table.setModel(model);This sample will only provide columns for month and year.
final JTable table = new JTable(); final ReflectedTableModel model = new ReflectedTableModel(); model.getRows().add( new Date() ); model.getColumns().add( new ReflectedTableModel.ColumnInfo("month") ); model.getColumns().add( new ReflectedTableModel.ColumnInfo("year") ); table.setModel(model);Tip: To enable debugging information call setTraceChannel with a non-null TraceChannel.
model.setTraceChannel(Trace.out)
Version: $Revision: 1.7 $
Nested Class Summary | |
---|---|
static class | ReflectedTableModel.ColumnInfo
This class contains information about one specific column in the table. |
class | ReflectedTableModel.RowElementControlData |
Field Summary | |
---|---|
NotificationListListener | columnListener_
If any change occurs to the columns then fire a structure changed. |
List | columns_ |
static Object[] | EMPTY_OBJECT_ARRAY |
PropertyChangeListener | propertyChangeListener_ |
Map | rowElementControlDatas_ |
NotificationListListener | rowListener_
If the row list changes then fire the appropriate table event. |
List | rows_ |
static long | serialVersionUID |
TraceChannel | traceChannel_ |
Constructor Summary | |
---|---|
ReflectedTableModel()
Create an empty model with no columns and no rows. | |
ReflectedTableModel(Class clazz)
Create an empty model with no rows but the columns preset to match the
properties in the given class.
|
Method Summary | |
---|---|
void | addRowElement(Object object)
Add a row element |
void | addRowElements(List list) |
protected void | assertNotNull(String fieldName, Object object)
Throw an exception if the specified object is null |
int | getColumnCount()
Return the number of columns. |
String | getColumnName(int index)
Return the name of the column at the specified index. |
List | getColumns()
Return a list containing the ColumnInfo objects that are used to define each
column. |
int | getRowCount()
Return the number of rows. |
List | getRows()
Return a list containing the objects that are used to create each row. |
TraceChannel | getTraceChannel()
Return the channel currently being used for tracing or null if tracing
is disabled. |
Object | getValueAt(int rowIndex, int columnIndex)
Return the specified object. |
void | removeRowElement(Object object)
Remove one row |
void | removeRowElements(List list) |
void | setTraceChannel(TraceChannel channel)
Set the channel to be used for tracing.
|
Parameters: clazz The class to get properties from.
Throws: IntrospectionException If the Introspector is unable to get the properties for this class.
Parameters: object the object that will be used to populate this row
Parameters: list The list of objects that will be used to create the rows.
Parameters: fieldName The name of the paremeter we are checking object The value of the parameter we are checking
Returns: the number of columns.
Parameters: index The index of the column.
Returns: The name of the column at the specified index.
Returns: The columns.
Returns: The number of rows.
Returns: The rows.
Returns: The trace channel or null if a channel hasn't been set.
Parameters: rowIndex The row index columnIndex The columnIndex
Returns: The object at the specified row and column.
Parameters: object The object that was used to create this row.
Parameters: list The list of object that will be removed from the model
Parameters: channel The channel to be used for tracing or null if tracing is to be disabled.