This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am updating a JTable with table.setValueAt(obj val, row, col); but all the rows show the data from the last entry. The code copies the values from a class into the table using setValueAt(). i have tried to manually call firedata change commands with no change. The table is created with the Default Table Model and I am not doing anything different. The debugger shows the correct data at the setValueAt() call.
I was going to suggest that, since you have a reference to the table model, you should be calling setValueAt() on the table model. But I see (at line 47 to 59) that you have some code which modifies the contents of the table model in a radical way before you call setValueAt(). That seems kind of fishy to me.
Also, the code at lines 51 to 53 has a hidden gotcha, in that it won't actually remove all of the rows from the model (assuming the table model stores its data in an ordinary way).
Can you show us the code for your table model, or is it one of the standard Swing classes?
Joined: Oct 22, 2012
The table uses the default table model settings, nothing changed. The table rows are added and deleted so there needs to be a way to re-size during run time. The table does re-size but all the rows show the data of the last row.