Link to home
Start Free TrialLog in
Avatar of Brock20
Brock20

asked on

Keeping track of JTable changes

Hi,
  I am writing an application that displays database tables in a JTable object.  I am using this dialog to allow the user to make changes to the table.  I am having a hard time designing a way to keep track of user changes.  I want to be able to know when the user has made changes so I can save the data to the database.  

Later down the road I also may implement an undo feature and may want to keep track of the user changes in general.  I have not found much documentation on the web and was wondering if anyone would be able to help?

Thanks for all your help!!
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Just make a copy of your TableModel
Avatar of Brock20
Brock20

ASKER

So I should have a copy of the TableModel and then compare the data?  Wouldn't this take up resourses?  I was trying to think of a way to have the model or the view know that something has changed.  Not sure if that is the proper way to do it.
It depends what you want to do. If you don't need to know what the changes are, but merely that changes did occur, just calculate the hash code before and after
Avatar of Brock20

ASKER

1.)  How would I calculate the hash code?

2.)  So if I want to know what the changes are you are suggesting to keep two copies of my model?  Is this expensive?  
ASKER CERTIFIED SOLUTION
Avatar of ksivananth
ksivananth
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial