public class TableEditorModel extends AbstractTableModel
listenerList
Constructor and Description |
---|
TableEditorModel()
Constructs a default
DefaultTableModel which is a table of zero columns and zero rows. |
Modifier and Type | Method and Description |
---|---|
void |
addColumn(String name,
Class type) |
void |
addRow() |
void |
addRow(int idx) |
void |
clear() |
void |
copyInto(TableModel model) |
TableModel |
createModel() |
void |
fireTableCellUpdated(int row,
int column)
Notifies all listeners that the value of the cell at
[row, column] has been updated. |
void |
fireTableChanged(TableModelEvent e)
Forwards the given notification event to all
TableModelListeners that registered themselves as
listeners for this table model. |
void |
fireTableDataChanged()
Notifies all listeners that all cell values in the table's rows may have changed.
|
void |
fireTableRowsDeleted(int firstRow,
int lastRow)
Notifies all listeners that rows in the range
[firstRow, lastRow] , inclusive, have been deleted. |
void |
fireTableRowsInserted(int firstRow,
int lastRow)
Notifies all listeners that rows in the range
[firstRow, lastRow] , inclusive, have been inserted. |
void |
fireTableRowsUpdated(int firstRow,
int lastRow)
Notifies all listeners that rows in the range
[firstRow, lastRow] , inclusive, have been updated. |
void |
fireTableStructureChanged()
Notifies all listeners that the table's structure has changed.
|
Class<?> |
getColumnClass(int columnIndex)
Returns
Object.class regardless of columnIndex . |
int |
getColumnCount()
Returns the number of columns in the model.
|
String |
getColumnName(int column)
Returns a default name for the column using spreadsheet conventions: A, B, C, ...
|
int |
getRowCount()
Returns the number of rows in the model.
|
Object |
getValueAt(int rowIndex,
int columnIndex)
Returns the value for the cell at
columnIndex and rowIndex . |
boolean |
isCellEditable(int rowIndex,
int columnIndex)
Returns false.
|
boolean |
isSuspendEvents() |
void |
removeColumn(int column) |
void |
removeRow(int row) |
void |
setColumnClass(int index,
Class type) |
void |
setColumnName(int index,
String identifier) |
void |
setSuspendEvents(boolean suspendEvents) |
void |
setValueAt(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.
|
addTableModelListener, findColumn, getListeners, getTableModelListeners, removeTableModelListener
public TableEditorModel()
DefaultTableModel
which is a table of zero columns and zero rows.public void setColumnName(int index, String identifier)
public void removeColumn(int column)
public void removeRow(int row)
public void addRow()
public void addRow(int idx)
public String getColumnName(int column)
column
cannot be found, returns an empty string.getColumnName
in interface TableModel
getColumnName
in class AbstractTableModel
column
- the column being queriedcolumn
public Class<?> getColumnClass(int columnIndex)
Object.class
regardless of columnIndex
.getColumnClass
in interface TableModel
getColumnClass
in class AbstractTableModel
columnIndex
- the column being queriedpublic int getRowCount()
JTable
uses this method to determine how many rows it
should display. This method should be quick, as it is called frequently during rendering.getColumnCount()
public int getColumnCount()
JTable
uses this method to determine how many columns it
should create and display by default.getRowCount()
public Object getValueAt(int rowIndex, int columnIndex)
columnIndex
and rowIndex
.rowIndex
- the row whose value is to be queriedcolumnIndex
- the column whose value is to be queriedpublic boolean isCellEditable(int rowIndex, int columnIndex)
isCellEditable
in interface TableModel
isCellEditable
in class AbstractTableModel
rowIndex
- the row being queriedcolumnIndex
- the column being queriedpublic void setValueAt(Object aValue, int rowIndex, int columnIndex)
setValueAt
in interface TableModel
setValueAt
in class AbstractTableModel
aValue
- value to assign to cellrowIndex
- row of cellcolumnIndex
- column of cellpublic void clear()
public void setColumnClass(int index, Class type)
public void fireTableDataChanged()
JTable
should redraw the table from scratch. The structure of the table (as in the
order of the columns) is assumed to be the same.fireTableDataChanged
in class AbstractTableModel
TableModelEvent
,
EventListenerList
,
JTable.tableChanged(javax.swing.event.TableModelEvent)
public void fireTableStructureChanged()
JTable
receives this
event and its autoCreateColumnsFromModel
flag is set it discards any table columns that it had and
reallocates default columns in the order they appear in the model. This is the same as calling
setModel(TableModel)
on the JTable
.fireTableStructureChanged
in class AbstractTableModel
TableModelEvent
,
EventListenerList
public void fireTableRowsInserted(int firstRow, int lastRow)
[firstRow, lastRow]
, inclusive, have been inserted.fireTableRowsInserted
in class AbstractTableModel
firstRow
- the first rowlastRow
- the last rowTableModelEvent
,
EventListenerList
public void fireTableRowsUpdated(int firstRow, int lastRow)
[firstRow, lastRow]
, inclusive, have been updated.fireTableRowsUpdated
in class AbstractTableModel
firstRow
- the first rowlastRow
- the last rowTableModelEvent
,
EventListenerList
public void fireTableRowsDeleted(int firstRow, int lastRow)
[firstRow, lastRow]
, inclusive, have been deleted.fireTableRowsDeleted
in class AbstractTableModel
firstRow
- the first rowlastRow
- the last rowTableModelEvent
,
EventListenerList
public void fireTableCellUpdated(int row, int column)
[row, column]
has been updated.fireTableCellUpdated
in class AbstractTableModel
row
- row of cell which has been updatedcolumn
- column of cell which has been updatedTableModelEvent
,
EventListenerList
public void fireTableChanged(TableModelEvent e)
TableModelListeners
that registered themselves as
listeners for this table model.fireTableChanged
in class AbstractTableModel
e
- the event to be forwardedTableModelEvent
,
EventListenerList
public boolean isSuspendEvents()
public void setSuspendEvents(boolean suspendEvents)
public void copyInto(TableModel model)
public TableModel createModel()
Copyright © 2019 Hitachi Vantara. All rights reserved.