I try to limit the number of allowable characters to 5 by using
try {
jFormattedTextField2.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("*****")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
However, when I only enter 1 character, there will always be 4 others space being padded. How can I avoid the padding, at the same time limiting number of characters?