public class ArrayTableModel
extends javax.swing.table.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.Constructor and Description |
---|
ArrayTableModel()
Constructs a model with no columns or rows.
|
ArrayTableModel(ArrayTableColumn[] columns,
java.lang.Object[] items)
Constructs a model with a given set of columns and rows.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Class |
getColumnClass(int icol) |
int |
getColumnCount() |
java.lang.String |
getColumnName(int icol) |
ArrayTableColumn[] |
getColumns()
Returns the column specifiers used by this table.
|
java.lang.Object[] |
getItems()
Returns the row data items used by this model.
|
int |
getRowCount() |
java.lang.Object |
getValueAt(int irow,
int icol) |
void |
setColumns(ArrayTableColumn[] columns)
Sets the column specifiers to be used by this table.
|
void |
setItems(java.lang.Object[] 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()
public ArrayTableModel(ArrayTableColumn[] columns, java.lang.Object[] items)
columns
- array of column specifiersitems
- array of row data objectspublic void setColumns(ArrayTableColumn[] columns)
columns
- column specifierspublic ArrayTableColumn[] getColumns()
public void setItems(java.lang.Object[] items)
items
- row data items, one per rowpublic java.lang.Object[] 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 java.lang.Object getValueAt(int irow, int icol)
public java.lang.String getColumnName(int icol)
getColumnName
in interface javax.swing.table.TableModel
getColumnName
in class javax.swing.table.AbstractTableModel
public java.lang.Class getColumnClass(int icol)
getColumnClass
in interface javax.swing.table.TableModel
getColumnClass
in class javax.swing.table.AbstractTableModel
Copyright © 2017 Central Laboratory of the Research Councils. All Rights Reserved.