I can't seem to get my table to refresh. I created a refresh button that calls jTable1.repaint();
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt)
// Reader Refresh
jTable1.repaint();
}
I also tried just recalling the RegistryValues
again in the button like RegistryValues.arp(null);
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt)
// Reader Refresh
RegistryValues.arp(null);
}
Also tried combining the registryvalues and repaint in the button.
Below is the code for my jTable
. The RegistryValues
are from another class that uses JNA to read the registry if that matters.
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{"Protected Mode at Startup", RegistryValues.arp(null)},
{"Display PDF in browser", RegistryValues.arb(null)},
{"EULA Accepted?", RegistryValues.are(null)},
{null, null}
},
new String [] {
"Software", "Status"
}
));
Neither
or
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:
Note: You could save the model as a class member variable and eliminate the need for casting.