Win a copy of Head First Android this week in the Android forum!
  • 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

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.
author and jackaroo
Posts: 12199
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
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic