• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

old values from the JTable

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic