aspose file tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes old values from the JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "old values from the JTable" Watch "old values from the JTable" New topic
Author

old values from the JTable

Arun Kumar
Ranch Hand

Joined: Aug 29, 2003
Posts: 67
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


SCJP (1.4), SCWCD, SCJD
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 10892
    
  26

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


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: old values from the JTable
 
Similar Threads
JTable
JTable
refreshing a JTable
JTable
JTable