-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
6u43, 7, 8, 11, 12, 13, 14, 15
We setup JFormattedTextField as follows:
MaskFormatter formatter = new MaskFormatter("##-##-##");
JFormattedTextField fmtFld1 = new JFormattedTextField(formatter);
fmtFld1.addFocusListener(focusListener);
Then we correctly fill fmtFld1 with some value such as 11-11-11
Then we press Tab key so the field looses focus.
When it looses focus focusListener.focusLost() gets called. In it we are acquiring the field's value with fmtFld1.getValue().
However it reports null, and not the correct value.
If we call getValue() ourselves some time before that then null is no more reported.
This behaviour does not happen with other formatters, but with MaskFormatter only.
The attached program demonstrates the issue. To see the issue run the program, type 11-11-11 in the first field and press tab. In the console there will be printed null and not 11-11-11
MaskFormatter formatter = new MaskFormatter("##-##-##");
JFormattedTextField fmtFld1 = new JFormattedTextField(formatter);
fmtFld1.addFocusListener(focusListener);
Then we correctly fill fmtFld1 with some value such as 11-11-11
Then we press Tab key so the field looses focus.
When it looses focus focusListener.focusLost() gets called. In it we are acquiring the field's value with fmtFld1.getValue().
However it reports null, and not the correct value.
If we call getValue() ourselves some time before that then null is no more reported.
This behaviour does not happen with other formatters, but with MaskFormatter only.
The attached program demonstrates the issue. To see the issue run the program, type 11-11-11 in the first field and press tab. In the console there will be printed null and not 11-11-11