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]

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.
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.