I'm using JFormattedTextFields to automatically manage several numeric text fields on an Applet. When the Applet's form is processed the data is collected from the form and written to a MySql database. Each text box is then set to blank, i.e., field.setText("").
So far, so good. However, if I click in the blank text box then click somewhere else, the value that was previously entered will reappear. This if very problematic.
I found the answer while preparing the post, but it might be useful to someone, so here's the solution.
The default behavior for losing focus is COMMIT_OR_REVERT
Apparently, the component recalls the last valid entry in the field when focus is lost. Sounds like a feature, but a big problem for me.
To fix this, I set the lost focus behavior for each field declared as a JFormattedTextField, e.g.: field.setFocusLostBehavior(JFormattedTextField.PER SIST);
Having said that, if anyone knows of a problem with this solution, please chime in!