我想要一个JTextField只接受我指定的模式。“12ABCDE1234A1A1”
注意 - 该模式可以包含任何数字和字母。
JTextField t17 = new JTextField();
final String match ="(\\d\\d)-([a-zA-z]{5})-(\\d\\d\\d\\d)-([a-zA-z]{1})-
(\\d)-([a-zA-z]{1})-(\\d)+$";
Pattern pt = Pattern.compile(match);
final Matcher mt =pt.matcher(t17.getText());
t17.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent arg0) {
if(mt.matches()){
lblPin.setText("verified");
}else{
JOptionPane op = new JOptionPane();
op.showMessageDialog(iff, "INVALID GST NUMBER");
}
}
});
UYOU
鸿蒙传说
相关分类