在让 JFormattedTextField 与我的自定义格式一起工作感到非常沮丧之后,我想知道是否有 a Formatter
orFormatterFactory
使用正则表达式?
我的想法是,如果有,那么我可以将它包装在一个静态类中并像这样调用它:
mFormattedTextField.setFormatterFactory(
SomeStaticClass.getRegexFormatFactory("^(\\d{1,}h)(\\s([0-5])?[0-9]m)?$"));
有关更多背景信息,请参阅我之前的问题:
“我想使用 JFormattedTextField 来允许用户将持续时间值输入到表单中。示例有效值是:2h 30m
72h 15m
6h
0h
”