T
- Data type housed in the modelpublic class ListTableModel<T>
extends javax.swing.table.AbstractTableModel
Modifier and Type | Field and Description |
---|---|
private java.util.List<java.lang.String> |
columnNames
Column names
|
private java.util.List<java.util.List<T>> |
rowData
Row data
|
private static long |
serialVersionUID
Serial UID
|
Constructor and Description |
---|
ListTableModel()
Setup the instance with empty column and data lists
|
Modifier and Type | Method and Description |
---|---|
void |
addColumn(java.lang.String colName)
Add a column name to the model
|
void |
addRow(java.util.List<T> row)
Add a data row to the model and notify the table that its model has changed
|
void |
addRowFast(java.util.List<T> row)
Add a data row to the model witout notifying the table that the model has
changed
|
int |
getColumnCount()
Get the number of columns in the model (based on number of column names)
|
java.lang.String |
getColumnName(int col)
Get the column name for the requested column
|
int |
getRowCount()
Get the number of data rows in the model
|
T |
getValueAt(int row,
int col)
Get the value for a row and column
|
void |
setColumnIdentifiers(java.util.List<java.lang.String> cols)
Set the list of column names for the model
|
void |
updateCompleted()
Notify the table that the model has changed.
|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
private static final long serialVersionUID
private java.util.List<java.lang.String> columnNames
private java.util.List<java.util.List<T>> rowData
public ListTableModel()
public void setColumnIdentifiers(java.util.List<java.lang.String> cols)
cols
- The list of column namespublic void addColumn(java.lang.String colName)
colName
- The column namepublic java.lang.String getColumnName(int col)
getColumnName
in interface javax.swing.table.TableModel
getColumnName
in class javax.swing.table.AbstractTableModel
col
- The column numberpublic void addRow(java.util.List<T> row)
row
- The data row (a list of objects, one per columns)addRowFast(List)
public void addRowFast(java.util.List<T> row)
row
- The data row (a list of objects, one per columnsupdateCompleted()
public void updateCompleted()
addRowFast(List)
public int getColumnCount()
public int getRowCount()
public T getValueAt(int row, int col)
row
- The row numbercol
- The column number