title: Limit number of characters in JTextField
body: <p>I try to limit the number of allowable characters to 5 by using</p>
  
  <pre><code>    try {
          jFormattedTextField2.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("*****")));
      } catch (java.text.ParseException ex) {
          ex.printStackTrace();
      }
  </code></pre>
  
  <p>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?</p>