This content has been marked as final. Show 4 replies
Don't understand the question much, but from what I think I get, try JFormattedTextField.trim().
Here's the scenario.
I start with a field to enter a year which is currently blank.
I enter '2000' but then I decide I want the field to be blank again.
I backspace 4 times to delete the four characters. The three 0's are deleted but the field will not let me delete the '2'. It just beeps at me.
If I enter an additional character and then move the caret over to the '2' and then press backspace I can delete it, but I still have something in the field and I want the field totally blank.
I also cannot highlite the data and press the delete key to get rid of it. It won't allow that either.
I meet the same problem, but have unfortunately no solution. However, I read that there is at least one bug in JFormattedTextField
Although its description has nothing to do with our case but cuts the last character instead, maybe there are still unobserved side effects.
I realize this is an old post, but I think the solution is in the formatter.
call getFormatter() of your JFormattedTextField.
on the formatter you get set the allowsInvalid property to true.
I think this should solve your problem.