Package: groovy.swing.model

## [Java] Class DefaultTableModel

- groovy.swing.model.DefaultTableModel

-     public class DefaultTableModel
      extends AbstractTableModel

  A table model built from row and column ValueModel instances.

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `protected static class` | `DefaultTableModel.MyTableColumnModel` | Column model implementation that keeps model indexes aligned with the current column order.

  - ### Constructor Summary

    Constructors
    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.

  - ### Methods Summary

    Methods
    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()` Returns: the column definitions.
    `` | `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()`
    `` | `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.

  - ### Inherited Methods Summary

    Inherited Methods
    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`

- - ### Constructor Detail

    - #### public DefaultTableModel(ValueModel rowsModel)

      Creates a table model with its own row holder.

      Parameters:
        `rowsModel` - the model that supplies the row collection

    - #### public DefaultTableModel(ValueModel rowsModel, ValueModel rowModel)

      Creates a table model with explicit row and rows models.

      Parameters:
        `rowsModel` - the model that supplies the row collection
        `rowModel` - the model reused for exposing the current row

  - ### Method Detail

    - #### 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.

      Parameters:
        `headerValue` - the header value and identifier
        `columnValueModel` - the value model used by the column
      Returns:
        the created column

    - #### public DefaultTableColumn addColumn(Object headerValue, Object identifier, ValueModel columnValueModel)

      Adds a column definition with an explicit identifier.

      Parameters:
        `headerValue` - the header value
        `identifier` - the column identifier
        `columnValueModel` - the value model used by the column
      Returns:
        the created column

    - #### 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.

      Parameters:
        `columnIndex` - the column index
      Returns:
        the column value type

    - #### public int getColumnCount()

      Returns the number of configured columns.

      Returns:
        the current column count

    - #### public List getColumnList()

      Returns:
        the column definitions.

    - #### public TableColumnModel getColumnModel()

      Returns the Swing column model maintained by this table model.

      Returns:
        the column model

    - #### protected ValueModel getColumnModel(int columnIndex)

      Returns the value model used by the supplied column.

      Parameters:
        `columnIndex` - the column index
      Returns:
        the column value model

    - #### public String getColumnName(int columnIndex)

      Returns the header text for the supplied column.

      Parameters:
        `columnIndex` - the column index
      Returns:
        the column header text, or `null` when unavailable

    - #### public int getRowCount()

      Returns the number of rows currently exposed by the rows model.

      Returns:
        the current row count

    - #### public ValueModel getRowModel()

      Returns the value model representing the current row object.

      Returns:
        the current row model

    - #### protected List getRows()

    - #### public ValueModel getRowsModel()

      Returns the model that supplies the backing row collection.

      Returns:
        the rows model

    - #### public Object getValueAt(int rowIndex, int columnIndex)

      Reads the value for the supplied row and column.

      Parameters:
        `rowIndex` - the row index
        `columnIndex` - the column index
      Returns:
        the cell value, or `null` when the coordinates are invalid

    - #### public boolean isCellEditable(int rowIndex, int columnIndex)

      Indicates whether the supplied cell can be edited through its column model.

      Parameters:
        `rowIndex` - the row index
        `columnIndex` - the column index
      Returns:
        `true` when the column model is editable

    - #### 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.

      Parameters:
        `value` - the new cell value
        `rowIndex` - the row index
        `columnIndex` - the column index