title: JFormattedTextField with a maskFormatter throws NumberFormatException
body: <p>I have a JFormattedTextField using the following mask formatter:</p>
  
  <pre><code>    private MaskFormatter maskForInput;
      maskForInput=new MaskFormatter("####"); // I have tried using stars (*) too.
      maskForInput.setValidCharacters("0123456789");
  
      javax.swing.JFormattedTextField playerRaiseField=new javax.swing.JFormattedTextField(maskForInput);
  </code></pre>
  
  <p>This is supposed to allow the user to enter up to 4 digits as an input. However when I am trying to <code>Integer.parseInt(playerRaiseField.getText())</code> the <code>String</code> returned from this field I am always getting a <code>NumberFormatException</code> possibly due to the empty spaces left on user input.
  To clear this up:</p>
  
  <p>If the user inputs <code>560</code> for example there is a trailing space left behind so the String I am reading is <code>560( )</code> and when trying to parse this <code>String</code> into an <code>int</code> this exception is thrown. Any workarounds? How can I modify the mask formatter to accept 1 to 4 digits and <em>not</em> always 4 digits fixed??</p>
  
  <p><strong>Note:</strong> Curiously enough using <code>trim()</code> on the <code>String</code> returned is still not removing the extra whitespace character...</p>