我想触发一个事件,该事件表示给定的列值都已更改,即X列中的某些值已更改。我该怎么办,因为所有事件都涉及单元格,行或整个数据表...
最佳答案
在AbstractTableModel
中,似乎显式构造TableModelEvent
可能会达到目的:
model.fireTableChanged(new TableModelEvent(model, 0, lastRow, columnIndex,
TableModelEvent.UPDATE));
另请参见
TableModelEvent
的javadoc:/**
* Depending on the parameters used in the constructors, the TableModelevent
* can be used to specify the following types of changes: <p>
*
* <pre>
* TableModelEvent(source); // The data, ie. all rows changed
* TableModelEvent(source, HEADER_ROW); // Structure change, reallocate TableColumns
* TableModelEvent(source, 1); // Row 1 changed
* TableModelEvent(source, 3, 6); // Rows 3 to 6 inclusive changed
* TableModelEvent(source, 2, 2, 6); // Cell at (2, 6) changed
* TableModelEvent(source, 3, 6, ALL_COLUMNS, INSERT); // Rows (3, 6) were inserted
* TableModelEvent(source, 3, 6, ALL_COLUMNS, DELETE); // Rows (3, 6) were deleted
* </pre>
*
* It is possible to use other combinations of the parameters, not all of them
* are meaningful. (...)