javax.swing.table
public abstract class AbstractTableModel extends Object implements TableModel, Serializable
TableModel
interface.Modifier and Type | Field and Description |
---|---|
protected EventListenerList |
listenerList
Storage for the listeners registered with this model.
|
Constructor and Description |
---|
AbstractTableModel()
Creates a default instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addTableModelListener(TableModelListener listener)
Adds a listener to the table model.
|
int |
findColumn(String columnName)
Return the index of the specified column, or
-1 if there is
no column with the specified name. |
void |
fireTableCellUpdated(int row,
int column)
Sends a
TableModelEvent to all registered listeners to inform
them that a single cell has been updated. |
void |
fireTableChanged(TableModelEvent event)
Sends the specified event to all registered listeners.
|
void |
fireTableDataChanged()
Sends a
TableModelEvent to all registered listeners to inform
them that the table data has changed. |
void |
fireTableRowsDeleted(int firstRow,
int lastRow)
Sends a
TableModelEvent to all registered listeners to inform
them that some rows have been deleted from the model. |
void |
fireTableRowsInserted(int firstRow,
int lastRow)
Sends a
TableModelEvent to all registered listeners to inform
them that some rows have been inserted into the model. |
void |
fireTableRowsUpdated(int firstRow,
int lastRow)
Sends a
TableModelEvent to all registered listeners to inform
them that some rows have been updated. |
void |
fireTableStructureChanged()
Sends a
TableModelEvent to all registered listeners to inform
them that the table structure has changed. |
Class<?> |
getColumnClass(int columnIndex)
Returns the
Class for all Object instances
in the specified column. |
String |
getColumnName(int columnIndex)
Returns the name of the specified column.
|
<T extends EventListener> |
getListeners(Class<T> listenerType)
Returns an array of listeners of the given type that are registered with
this model.
|
TableModelListener[] |
getTableModelListeners()
Returns an array containing the listeners that have been added to the
table model.
|
boolean |
isCellEditable(int rowIndex,
int columnIndex)
Returns
true if the specified cell is editable, and
false if it is not. |
void |
removeTableModelListener(TableModelListener listener)
Removes a listener from the table model so that it will no longer receive
notification of changes to the table model.
|
void |
setValueAt(Object value,
int rowIndex,
int columnIndex)
Sets the value of the given cell.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getColumnCount, getRowCount, getValueAt
protected EventListenerList listenerList
public AbstractTableModel()
public String getColumnName(int columnIndex)
getColumnName
in interface TableModel
columnIndex
- the column index.public int findColumn(String columnName)
-1
if there is
no column with the specified name.columnName
- the name of the column (null
not permitted).NullPointerException
- if columnName
is
null
.getColumnName(int)
public Class<?> getColumnClass(int columnIndex)
Class
for all Object
instances
in the specified column.getColumnClass
in interface TableModel
columnIndex
- the column index.public boolean isCellEditable(int rowIndex, int columnIndex)
true
if the specified cell is editable, and
false
if it is not. This implementation returns
false
for all arguments, subclasses should override the
method if necessary.isCellEditable
in interface TableModel
rowIndex
- the row index of the cell.columnIndex
- the column index of the cell.false
.public void setValueAt(Object value, int rowIndex, int columnIndex)
setValueAt
in interface TableModel
value
- the new value (null
permitted).rowIndex
- the row index of the cell.columnIndex
- the column index of the cell.public void addTableModelListener(TableModelListener listener)
addTableModelListener
in interface TableModel
listener
- the listener.public void removeTableModelListener(TableModelListener listener)
removeTableModelListener
in interface TableModel
listener
- the listener to remove.public TableModelListener[] getTableModelListeners()
TableModelListener
objects.public void fireTableDataChanged()
TableModelEvent
to all registered listeners to inform
them that the table data has changed.public void fireTableStructureChanged()
TableModelEvent
to all registered listeners to inform
them that the table structure has changed.public void fireTableRowsInserted(int firstRow, int lastRow)
TableModelEvent
to all registered listeners to inform
them that some rows have been inserted into the model.firstRow
- the index of the first row.lastRow
- the index of the last row.public void fireTableRowsUpdated(int firstRow, int lastRow)
TableModelEvent
to all registered listeners to inform
them that some rows have been updated.firstRow
- the index of the first row.lastRow
- the index of the last row.public void fireTableRowsDeleted(int firstRow, int lastRow)
TableModelEvent
to all registered listeners to inform
them that some rows have been deleted from the model.firstRow
- the index of the first row.lastRow
- the index of the last row.public void fireTableCellUpdated(int row, int column)
TableModelEvent
to all registered listeners to inform
them that a single cell has been updated.row
- the row index.column
- the column index.public void fireTableChanged(TableModelEvent event)
event
- the event to send.public <T extends EventListener> T[] getListeners(Class<T> listenerType)
listenerType
- the listener class.