Best way to implement refusing a value change by the user in Swing?

Posted by Michael Borgwardt on Stack Overflow See other posts from Stack Overflow or by Michael Borgwardt
Published on 2010-04-18T06:25:47Z Indexed on 2010/04/18 6:33 UTC
Read the original article Hit count: 307

Filed under:
|
|

I have a JCheckBox that should not be checked by the user when a certain other field is empty.

So now I want to have an error popup and then reset the checkbox (I've considered disabling the checkbox, but the connection to the other field is non-obvious, and a tooltip text IMO not visible enough).

What's the correct way to do that in Swing? Through a PropertyVetoException? Where do I throw it and where do I catch it? My first (probably ugly) idea would be to add a ChangeListener that itself shows the popup and resets the value.

© Stack Overflow or respective owner

Related posts about java

Related posts about swing