Refresh a jTable

若如初见. 提交于 2019-12-02 08:47:17

Neither

jTable1.repaint();

or

RegistryValues.arp(null);

will actually refresh the table with new values. For this you need to either update the current table model or set a new model but in your ActionListener.

As you're using DefaultTableModel, which is mutable, you could create an update helper method for the model.

Something like:

DefaultTableModel model = (DefaultTableModel) table.getModel();
model.setValueAt(RegistryValues.arp(null), 0, 1);
// set more row data, etc.

Note: You could save the model as a class member variable and eliminate the need for casting.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!