Reputation: 410
I created a format for my jFormattedTextField
MaskFormatter formatter = new MaskFormatter("###.###.###.###");
formatter.setValidCharacters("0123456789");
jFormattedTextField7 = new javax.swing.JFormattedTextField(formatter);
but anytime I try to insert a value in the jFormattedTextField, switching to another one to insert an input value, the one in the code gets empty again.
Upvotes: 0
Views: 170
Reputation: 324118
You haven't entered a number in each position, therefore it is considered invalid. Try:
textField.setFocusLostBehavior(JFormattedTextField.COMMIT);
Upvotes: 2