问题
I would like to "clear" a JFormattedTextField programmatically but if I simply call txtAny.setText("") it is doesn't work cause textfield's regex pattern in my case:
private final String FORMATTER_STRING_FLOAT =
"[\\p{Digit}\\p{Cntrl}]{1,32}(\\.[\\p{Digit}\\p{Cntrl}]{0,2})?";
that requires at least one digit.
So my question is: how can I obtain a regex pattern of a JFormattedTextField for at least further manual partial processing?
回答1:
Call setText(anyValidString)
rather than setText("")
来源:https://stackoverflow.com/questions/9412081/how-can-i-programmaticaly-check-what-is-allowed-input-of-a-jformattedtextfield