I'm experiencing problems when validating values in fields I currently validate whenever I loose focus on a field but the problem is that I display a message box each time the value is incorrect. So when you go into a new field and the last field had an incorrect value it will loose focus from the new field when the message box pops up and so it validates that field as well.
I tried flagging it when focus is gained (and only then validating it), but it seems to gain focus on the next field before it displays the message box and so reseting the flag.
My bad. No one was replying. Wasn't sure where it should go. I'm a newbie. Forgive me.
posted 12 years ago
validating/error message scenario in focusLost is generally a bad idea.
InputVerifier() is a much better solution, and perhaps a JFormattedTextField or DocumentFilter even better. Depends on whether you want an error message displayed, or instead, just have the textfield not accept erroneous input