TableModel
interface. It takes care of
the management of listeners and provides some conveniences for generating
TableModelEvents
and dispatching them to the listeners.
To create a concrete TableModel
as a subclass 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. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans
package.
Please see java.
.
Modifier and Type | Field and Description |
---|---|
protected EventListenerList | listenerList
List of listeners |
Access | Constructor and Description |
---|---|
protected |
Modifier and Type | Method and Description |
---|---|
public void | addTableModelListener(TableModelListener
the TableModelListener l)Implements javax. Adds a listener to the list that's notified each time a change to the data model occurs. |
public int | Returns: the column withcolumnName , or -1 if not foundstring containing name of column to be located columnName)Returns a column given its name. |
public void | fireTableCellUpdated(int
row of cell which has been updated row, int column of cell which has been updated column)Notifies all listeners that the value of the cell at
|
public void | fireTableChanged(TableModelEvent
the event to be forwarded e)Forwards the given notification event to all
|
public void | fireTableDataChanged()
Notifies all listeners that all cell values in the table's rows may have changed. |
public void | fireTableRowsDeleted(int
the first row firstRow, int the last row lastRow)Notifies all listeners that rows in the range
|
public void | fireTableRowsInserted(int
the first row firstRow, int the last row lastRow)Notifies all listeners that rows in the range
|
public void | fireTableRowsUpdated(int
the first row firstRow, int the last row lastRow)Notifies all listeners that rows in the range
|
public void | |
public Class | Returns: the Object.classthe column being queried columnIndex)Implements javax. Returns |
public String | Returns: a string containing the default name ofcolumn the column being queried column)Implements javax. Returns a default name for the column using spreadsheet conventions: A, B, C, ... |
public < the listener type T extends EventListener> T[] | Returns: an array of all objects registered asFooListener s on this component,
or an empty array if no such
listeners have been addedthe type of listeners requested listenerType)Returns an array of all the objects currently registered
as |
public TableModelListener[] | Returns: all of this model'sTableModelListener s
or an empty
array if no table model listeners are currently registeredReturns an array of all the table model listeners registered on this model. |
public boolean | Returns: falsethe row being queried rowIndex, int the column being queried columnIndex)Implements javax. Returns false. |
public void | removeTableModelListener(TableModelListener
the TableModelListener l)Implements javax. Removes a listener from the list that's notified each time a change to the data model occurs. |
public void | setValueAt(Object
value to assign to cell aValue, int row of cell rowIndex, int column of cell columnIndex)Implements javax. This empty implementation is provided so users don't have to implement this method if their data model is not editable. |
listenerList | back to summary |
---|---|
protected EventListenerList listenerList List of listeners |
AbstractTableModel | back to summary |
---|---|
protected AbstractTableModel() Constructor for subclasses to call. |
addTableModelListener | back to summary |
---|---|
public void addTableModelListener(TableModelListener l) Implements javax. Adds a listener to the list that's notified each time a change to the data model occurs.
|
findColumn | back to summary |
---|---|
public int findColumn(String columnName) Returns a column given its name.
Implementation is naive so this should be overridden if
this method is to be called often. This method is not
in the
|
fireTableCellUpdated | back to summary |
---|---|
public void fireTableCellUpdated(int row, int column) Notifies all listeners that the value of the cell at
|
fireTableChanged | back to summary |
---|---|
public void fireTableChanged(TableModelEvent e) Forwards the given notification event to all
|
fireTableDataChanged | back to summary |
---|---|
public void fireTableDataChanged() Notifies all listeners that all cell values in the table's
rows may have changed. The number of rows may also have changed
and the |
fireTableRowsDeleted | back to summary |
---|---|
public void fireTableRowsDeleted(int firstRow, int lastRow) Notifies all listeners that rows in the range
|
fireTableRowsInserted | back to summary |
---|---|
public void fireTableRowsInserted(int firstRow, int lastRow) Notifies all listeners that rows in the range
|
fireTableRowsUpdated | back to summary |
---|---|
public void fireTableRowsUpdated(int firstRow, int lastRow) Notifies all listeners that rows in the range
|
fireTableStructureChanged | back to summary |
---|---|
public void fireTableStructureChanged() Notifies 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
|
getColumnClass | back to summary |
---|---|
public Class Implements javax. Returns
|
getColumnName | back to summary |
---|---|
public String getColumnName(int column) Implements javax. Returns a default name for the column using spreadsheet conventions:
A, B, C, ... Z, AA, AB, etc. If
|
getListeners | back to summary |
---|---|
public <T extends EventListener> T[] getListeners(Class<T> listenerType) Returns an array of all the objects currently registered
as
You can specify the TableModelListener[] tmls = (TableModelListener[])(m.getListeners(TableModelListener.class));If no such listeners exist, this method returns an empty array.
|
getTableModelListeners | back to summary |
---|---|
public TableModelListener[] getTableModelListeners() Returns an array of all the table model listeners registered on this model.
|
isCellEditable | back to summary |
---|---|
public boolean isCellEditable(int rowIndex, int columnIndex) Implements javax. Returns false. This is the default implementation for all cells.
|
removeTableModelListener | back to summary |
---|---|
public void removeTableModelListener(TableModelListener l) Implements javax. Removes a listener from the list that's notified each time a change to the data model occurs.
|
setValueAt | back to summary |
---|---|
public void setValueAt(Object aValue, int rowIndex, int columnIndex) Implements javax. This empty implementation is provided so users don't have to implement this method if their data model is not editable.
|