public class ArrayTableModel<R> extends AbstractTableModel
ArrayTableSorter
class can be used in conjunction with
this class to provide tables which can be sorted by clicking on
column headers.
The model works by having an array of column objects which know how to
interrogate the array of data objects in such a way as to return cell
values. The implementation of the column and data item objects
is therefore interlinked.listenerList
Constructor and Description |
---|
ArrayTableModel(R[] items)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Class<?> |
getColumnClass(int icol) |
int |
getColumnCount() |
String |
getColumnName(int icol) |
List<ArrayTableColumn<R,?>> |
getColumns()
Returns the column specifiers used by this table.
|
R[] |
getItems()
Returns the row data items used by this model.
|
int |
getRowCount() |
Object |
getValueAt(int irow,
int icol) |
void |
setColumns(List<? extends ArrayTableColumn<? extends R,?>> columns)
Sets the column specifiers to be used by this table.
|
void |
setItems(R[] items)
Sets the row data items to be used by this table.
|
void |
sortByColumn(int icol,
boolean descending)
Sorts the rows in this table according to the ordering of the
data in one of the columns.
|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
public ArrayTableModel(R[] items)
items
- initial list of itemspublic void setColumns(List<? extends ArrayTableColumn<? extends R,?>> columns)
columns
- column specifierspublic List<ArrayTableColumn<R,?>> getColumns()
public void setItems(R[] items)
items
- row data items, one per rowpublic R[] getItems()
public void sortByColumn(int icol, boolean descending)
icol
- index of column to sort bydescending
- true to sort down, false to sort uppublic int getColumnCount()
public int getRowCount()
public Object getValueAt(int irow, int icol)
public String getColumnName(int icol)
getColumnName
in interface TableModel
getColumnName
in class AbstractTableModel
public Class<?> getColumnClass(int icol)
getColumnClass
in interface TableModel
getColumnClass
in class AbstractTableModel
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.