问题
How do I validate JTextField
for a personal number? For example, I would like it to validate something formatted like 841017-4567
.
回答1:
Read up on JFormattedTextField and MaskFormatter.
JFormattedTextField phoneField = new JFormattedTextField(new MaskFormatter("######-####"));
来源:https://stackoverflow.com/questions/4926745/validate-jtextfield