我想触发一个事件,该事件表示给定的列值已全部更改,即在 X 列的某处,某些值已更改。我该怎么做,因为所有事件都涉及单元格、行或整个数据表......
问问题
5541 次
2 回答
5
查看AbstractTableModel
,看起来像TableModelEvent
明确地构造一个可能会成功:
model.fireTableChanged(new TableModelEvent(model, 0, lastRow, columnIndex,
TableModelEvent.UPDATE));
另请参阅 javadoc TableModelEvent
:
/**
* 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. (...)
于 2012-08-08T09:31:56.520 回答
1
就我个人而言,如果只是为了指示表需要刷新,我会触发一个事件来说明整个表已更改。
于 2012-08-08T09:38:27.843 回答