How can I programmaticaly check what is allowed input of a JFormattedTextField?

我怕爱的太早我们不能终老 提交于 2019-12-11 11:21:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!