Vetoing a change by DefaultCellEditor in JTable  
Author Message
trin





PostPosted: 2003-8-27 8:47:00 Top

java-programmer, Vetoing a change by DefaultCellEditor in JTable I'm using a DefaultCellEditor with a JTextField to capture a String
that is ultimately passed to setValueAt in my TableModel. In that
method, I have logic which could throw an exception if the String's
contents proves to be invalid (i.e. one use is where the String is a
regular expression that might be syntactically invalid).

How can I handle this? Right now, the code throws an Exception which
I'd like to catch, display a dialog, and then return the user to
editing without ever committing the value. Is this easily doable?

Regards,
Brian.
 
Tor Iver Wilhelmsen





PostPosted: 2003-8-28 1:36:00 Top

java-programmer >> Vetoing a change by DefaultCellEditor in JTable email***@***.com (Brian J. Sayatovic) writes:

> How can I handle this? Right now, the code throws an Exception which
> I'd like to catch, display a dialog, and then return the user to
> editing without ever committing the value. Is this easily doable?

Override the TableModel's stopCellEditing() to catch the exception and
return false, otherwise return true.