且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JTable如何在插入删除或更新数据后刷新表模型。

更新时间:2023-12-03 12:45:04

如果您想通知您的 JTable 有关数据更改的信息,使用

tableModel.fireTableDataChanged()

If you want to notify your JTable about changes of your data, use
tableModel.fireTableDataChanged()

来自文档


通知所有侦听器表格行中的所有单元格值都可能已更改。行数也可能已更改,JTable应从头开始重绘表。表的结构(按列的顺序)假定是相同的。

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 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.