public class DefaultTableModel
extends AbstractTableModel
A table model built from row and column ValueModel instances.
| Modifiers | Name | Description |
|---|---|---|
protected static class |
DefaultTableModel.MyTableColumnModel |
Column model implementation that keeps model indexes aligned with the current column order. |
| Constructor and description |
|---|
DefaultTableModel(ValueModel rowsModel)Creates a table model with its own row holder. |
DefaultTableModel(ValueModel rowsModel, ValueModel rowModel)Creates a table model with explicit row and rows models. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public DefaultTableColumn |
addClosureColumn(Object headerValue, Closure readClosure, Closure writeClosure, Class type)Adds a closure based column to the table |
|
public DefaultTableColumn |
addColumn(Object headerValue, ValueModel columnValueModel)Adds a column whose header value is also used as its identifier. |
|
public DefaultTableColumn |
addColumn(Object headerValue, Object identifier, ValueModel columnValueModel)Adds a column definition with an explicit identifier. |
|
public void |
addColumn(DefaultTableColumn column)Adds a new column definition to the table |
|
public DefaultTableColumn |
addPropertyColumn(Object headerValue, String property, Class type)Adds a property model column to the table |
|
public DefaultTableColumn |
addPropertyColumn(Object headerValue, String property, Class type, boolean editable)Adds a property model column to the table |
|
public Class |
getColumnClass(int columnIndex)Returns the declared value type for the supplied column. |
|
public int |
getColumnCount()Returns the number of configured columns. |
|
public List |
getColumnList()
|
|
public TableColumnModel |
getColumnModel()Returns the Swing column model maintained by this table model. |
|
protected ValueModel |
getColumnModel(int columnIndex)Returns the value model used by the supplied column. |
|
public String |
getColumnName(int columnIndex)Returns the header text for the supplied column. |
|
public int |
getRowCount()Returns the number of rows currently exposed by the rows model. |
|
public ValueModel |
getRowModel()Returns the value model representing the current row object. |
|
protected List |
getRows()Returns the current rows as a list. |
|
public ValueModel |
getRowsModel()Returns the model that supplies the backing row collection. |
|
public Object |
getValueAt(int rowIndex, int columnIndex)Reads the value for the supplied row and column. |
|
public boolean |
isCellEditable(int rowIndex, int columnIndex)Indicates whether the supplied cell can be edited through its column model. |
|
public void |
removeColumn(DefaultTableColumn column)Removes a column definition from the table |
|
public void |
setValueAt(Object value, int rowIndex, int columnIndex)Writes a value to the supplied row and column when both coordinates are valid. |
| Methods inherited from class | Name |
|---|---|
class AbstractTableModel |
addTableModelListener, equals, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getClass, getColumnClass, getColumnCount, getColumnName, getListeners, getRowCount, getTableModelListeners, getValueAt, hashCode, isCellEditable, notify, notifyAll, removeTableModelListener, setValueAt, toString, wait, wait, wait |
Creates a table model with its own row holder.
rowsModel - the model that supplies the row collectionCreates a table model with explicit row and rows models.
rowsModel - the model that supplies the row collectionrowModel - the model reused for exposing the current rowAdds a closure based column to the table
Adds a column whose header value is also used as its identifier.
headerValue - the header value and identifiercolumnValueModel - the value model used by the columnAdds a column definition with an explicit identifier.
headerValue - the header valueidentifier - the column identifiercolumnValueModel - the value model used by the columnAdds a new column definition to the table
Adds a property model column to the table
Adds a property model column to the table
Returns the declared value type for the supplied column.
columnIndex - the column indexReturns the number of configured columns.
Returns the Swing column model maintained by this table model.
Returns the value model used by the supplied column.
columnIndex - the column indexReturns the header text for the supplied column.
columnIndex - the column indexnull when unavailableReturns the number of rows currently exposed by the rows model.
Returns the value model representing the current row object.
Returns the current rows as a list.
nullReturns the model that supplies the backing row collection.
Reads the value for the supplied row and column.
rowIndex - the row indexcolumnIndex - the column indexnull when the coordinates are invalidIndicates whether the supplied cell can be edited through its column model.
rowIndex - the row indexcolumnIndex - the column indextrue when the column model is editableRemoves a column definition from the table
Writes a value to the supplied row and column when both coordinates are valid.
value - the new cell valuerowIndex - the row indexcolumnIndex - the column indexCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.