Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.swing.table
Class AbstractTableModel

    java.lang.Object
      |
      +--javax.swing.table.AbstractTableModel

Direct Known Subclasses:
  DefaultTableModel

public abstract class AbstractTableModel
extends java.lang.Object
implements TableModel, java.io.Serializable

This abstract class provides default implementations for most of the methods in the TableModel interface. It takes care of the management of listners and provides some conveniences for generating TableModelEvents and dispatching them to the listeners. To create a concrete TableModel as a sublcass of AbstractTableModel you need only provide implementations for the following three methods:

      public int getRowCount();
      public int getColumnCount();
      public Object getValueAt(int row, int column);

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.

See Also:
  Serialized Form

Field Summary
`protected EventListenerList` | `listenerList` List of listeners

Constructor Summary
`AbstractTableModel()`

Method Summary
`void` | `addTableModelListener(TableModelListener l)` Add a listener to the list that's notified each time a change to the data model occurs.
`int` | `findColumn(java.lang.String columnName)` Convenience method for locating columns by name.
`void` | `fireTableCellUpdated(int row, int column)` Notify all listeners that the value of the cell at (row, column) has been updated.
`void` | `fireTableChanged(TableModelEvent e)` Forward the given notification event to all TableModelListeners that registered themselves as listeners for this table model.
`void` | `fireTableDataChanged()` Notify all listeners that all cell values in the table's rows may have changed.
`void` | `fireTableRowsDeleted(int firstRow, int lastRow)` Notify all listeners that rows in the (inclusive) range [firstRow, lastRow] have been deleted.
`void` | `fireTableRowsInserted(int firstRow, int lastRow)` Notify all listeners that rows in the (inclusive) range [firstRow, lastRow] have been inserted.
`void` | `fireTableRowsUpdated(int firstRow, int lastRow)` Notify all listeners that rows in the (inclusive) range [firstRow, lastRow] have been updated.
`void` | `fireTableStructureChanged()` Notify all listeners that the table's structure has changed.
`java.lang.Class` | `getColumnClass(int columnIndex)` Returns Object.class by default
`java.lang.String` | `getColumnName(int column)` Return a default name for the column using spreadsheet conventions: A, B, C, ...
`boolean` | `isCellEditable(int rowIndex, int columnIndex)` This default implementation returns false for all cells
`void` | `removeTableModelListener(TableModelListener l)` Remove a listener from the list that's notified each time a change to the data model occurs.
`void` | `setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)` This empty implementation is provided so users don't have to implement this method if their data model is not editable.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### listenerList

    protected EventListenerList listenerList

  List of listeners

Constructor Detail

### AbstractTableModel

    public AbstractTableModel()

Method Detail

### getColumnName

    public java.lang.String getColumnName(int column)

  Return a default name for the column using spreadsheet conventions: A, B, C, ... Z, AA, AB, etc.
  Specified by:
    getColumnName in interface TableModel

### findColumn

    public int findColumn(java.lang.String columnName)

  Convenience method for locating columns by name. Implementation is naive so this should be overridden if this method is to be called often. This method is not in the TableModel interface and is not used by the JTable.

### getColumnClass

    public java.lang.Class getColumnClass(int columnIndex)

  Returns Object.class by default
  Specified by:
    getColumnClass in interface TableModel

### isCellEditable

    public boolean isCellEditable(int rowIndex,
                                  int columnIndex)

  This default implementation returns false for all cells
  Specified by:
    isCellEditable in interface TableModel

### setValueAt

    public void setValueAt(java.lang.Object aValue,
                           int rowIndex,
                           int columnIndex)

  This empty implementation is provided so users don't have to implement this method if their data model is not editable.
  Specified by:
    setValueAt in interface TableModel

### addTableModelListener

    public void addTableModelListener(TableModelListener l)

  Add a listener to the list that's notified each time a change to the data model occurs.
  Specified by:
    addTableModelListener in interface TableModel
  Parameters:
    `l` - the TableModelListener

### removeTableModelListener

    public void removeTableModelListener(TableModelListener l)

  Remove a listener from the list that's notified each time a change to the data model occurs.
  Specified by:
    removeTableModelListener in interface TableModel
  Parameters:
    `l` - the TableModelListener

### fireTableDataChanged

    public void fireTableDataChanged()

  Notify all listeners that all cell values in the table's rows may have changed. The number of rows may also have changed and the JTable should redraw the table from scratch. The structure of the table, ie. the order of the columns is assumed to be the same.
  See Also:
    `TableModelEvent`, `EventListenerList`

### fireTableStructureChanged

    public void fireTableStructureChanged()

  Notify all listeners that the table's structure has changed. The number of columns in the table, and the names and types of the new columns may be different from the previous state. If the JTable recieves this event and its autoCreateColumnsFromModel flag is set it discards any TableColumns that it had and reallocates default ones in the order they appear in the model. This is the same as calling `setModel(TableModel)` on the JTable.
  See Also:
    `TableModelEvent`, `EventListenerList`

### fireTableRowsInserted

    public void fireTableRowsInserted(int firstRow,
                                      int lastRow)

  Notify all listeners that rows in the (inclusive) range [firstRow, lastRow] have been inserted.
  See Also:
    `TableModelEvent`, `EventListenerList`

### fireTableRowsUpdated

    public void fireTableRowsUpdated(int firstRow,
                                     int lastRow)

  Notify all listeners that rows in the (inclusive) range [firstRow, lastRow] have been updated.
  See Also:
    `TableModelEvent`, `EventListenerList`

### fireTableRowsDeleted

    public void fireTableRowsDeleted(int firstRow,
                                     int lastRow)

  Notify all listeners that rows in the (inclusive) range [firstRow, lastRow] have been deleted.
  See Also:
    `TableModelEvent`, `EventListenerList`

### fireTableCellUpdated

    public void fireTableCellUpdated(int row,
                                     int column)

  Notify all listeners that the value of the cell at (row, column) has been updated.
  See Also:
    `TableModelEvent`, `EventListenerList`

### fireTableChanged

    public void fireTableChanged(TableModelEvent e)

  Forward the given notification event to all TableModelListeners that registered themselves as listeners for this table model.
  See Also:
    `addTableModelListener(javax.swing.event.TableModelListener)`, `TableModelEvent`, `EventListenerList`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Submit a bug or feature
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.