我为 jFormattedTextField
创建了一种格式MaskFormatter formatter = new MaskFormatter("###.###.###.###");
formatter.setValidCharacters("0123456789");
jFormattedTextField7 = new javax.swing.JFormattedTextField(formatter);
但是当我尝试在 jFormattedTextField 中插入一个值时,切换到另一个值来插入输入值,代码中的那个值再次变空。
答案 0 :(得分:2)
您尚未在每个位置输入数字,因此被视为无效。尝试:
textField.setFocusLostBehavior(JFormattedTextField.COMMIT);