JTable issue on Lost of Focus

I noticed that my JTable wouldn't save the data on loss of focus, so search accross the forum and found this:

grid.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

Now it saves the data, the thing is, when it looses focus, the user may be clicking on a button which loads the next data set into the JTable, so instead of posting the data in the previous dataset, it seems to load the new data, then overwites the identical cell position with the new value.

Any establish solutions for this issue would be greatly appreciated.

Thanks

[576 byte] By [ditproz@itproz.co.uka] at [2007-11-26 17:47:43]
# 1
Try adding SwingUtilities.invokeLater in you button action listener.
Rodney_McKaya at 2007-7-9 5:00:02 > top of Java-index,Desktop,Core GUI APIs...
# 2
Not sure what you mean, I assume this is the same for a Tree, which is what the user clicks on.
ditproz@itproz.co.uka at 2007-7-9 5:00:02 > top of Java-index,Desktop,Core GUI APIs...
# 3

You said the user clicks on a button.

So then you get an action event into ActionPerformed funtion, where you load your next data set into the table.

Just wrap everything up inside SwingUtilities.invokeLater:

SwingUtilities.invokeLater(new Runnable() {

public void run() {

}

});

Put all the action code inside the run function.

Rodney_McKaya at 2007-7-9 5:00:02 > top of Java-index,Desktop,Core GUI APIs...
# 4
Thanks works a treat, assuming that this invokeLater, just reduces the priority of computing this code after everything else is done.
ditproz@itproz.co.uka at 2007-7-9 5:00:02 > top of Java-index,Desktop,Core GUI APIs...
# 5
Not really.Read the turorial: http://java.sun.com/docs/books/tutorial/uiswing/concurrency/initial.html
Rodney_McKaya at 2007-7-9 5:00:02 > top of Java-index,Desktop,Core GUI APIs...