JTable - Check for unsaved changes

Can anyone assist me on how I can check for whether there are unsaved changes in a JTable? I am trying to code the table check into a internal frame close event and not sure how to access the table to find out whether it contains any unsaved data.
[254 byte] By [jdkirbya] at [2007-9-30 2:20:17]
# 1
You are just going to have to keep a boolean around (call it "modified") that gets set to true when data is changed and then gets reset to false when you save.Hope this helps,Josh Castagno http://ww.jdc-software.com
Josh_Castagnoa at 2007-7-16 13:29:22 > top of Java-index,Archived Forums,Swing...
# 2
This seems like something best done in the table's model (I'm assuming you want to warn the user about pending unsaved changes before exiting the application). The table should just show what's in the model. The model can track state, such as the presence of unsaved changes.
mfriedera at 2007-7-16 13:29:22 > top of Java-index,Archived Forums,Swing...
# 3
That is exactly what I am trying to accomplish. Do you have any examples for getting the state of a model with unsaved changes?
jdkirbya at 2007-7-16 13:29:22 > top of Java-index,Archived Forums,Swing...
# 4

No examples, but I'd suggest

1. Reading about using tables in the Java tutorial (see http://java.sun.com/docs/books/tutorial/uiswing/components/table.html).

2. Create a custom table model that includes methods such as

public boolean isPending()

public void writeData() throws SQLException

Your exit processing can then check the model's pending flag. Your 'apply changes' button can call the model's writeData method.

mfriedera at 2007-7-16 13:29:22 > top of Java-index,Archived Forums,Swing...
# 5
Thanks for the help. That will get me headed in the right direction.
jdkirbya at 2007-7-16 13:29:22 > top of Java-index,Archived Forums,Swing...