Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

old values from the JTable

 
Arun Kumar
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok i am almost done with the assignment. But i am stuck with this problem
How do you get the old values (call this String[] oldData] of a particular row in the JTable before the user starts editing, say column 5 and column 6 in that row (call the new set of values String[] newData).
What i am planning to do is get the oldData and get the values of the same record number from the database, call it String[] dbData. Compare them, they should be equal. I will update that record in the database with the newData.
I think Phil is also using this technique.
But i am not able to get the old values from my tablemodel after the user changes the values. Seems like it updates the tablemodel with the latest changes being done to the JTable.
Any ideas how i should procced. I am using the AbstractTableModel.
Arun
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Arun,
I think you need to set a listener on either the table or the cell (sorry, it has been a long time since I did something like this, so I don't remember exactly).
You can add a listener to the table using AbstractTableModel's addTableModelListener() method. I think that at the point that you get notification that the cell has changed then you can still see the old value. But don't quote me on that.
Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic