title: Revert jTextField to last good value
body: <p>I have an <code>InputVerifier</code> for a <code>jTextField</code> to check and see if the input from the user is an integer.  If it is not, I want to revert it to the last good value.  How do I to this?  Here is the code I have so far:</p>
  
  <pre><code>class IntegerVerifier extends InputVerifier {
  
      public boolean verify(JComponent input) {
              JTextField text = (JTextField)input;
              String old = text.getText();
          try {
              Integer.parseInt(text.getText().trim());
          } catch (NumberFormatException e) {
              // this does not work b/c input is not a TextField
              input.setText(old); 
          }
          return true;
      }
  
  }
  </code></pre>
  
  <p><strong>EDIT:</strong> Below is what I ended up using as the solution.  I had actually tried this initially, but it appeared to not be working.  I discovered the error was in the testing.  I tried to change the textfield to an invalid value right after starting the gui, but it would blank out the field.  However, the textfield had focus as soon as the gui started, so it's initial value was null I think.  Subsequent changes behaved as expected.</p>
  
  <pre><code>class IntegerVerifier extends InputVerifier {
      public boolean verify(JComponent input) {
          JTextField text = (JTextField) input;
          String old = text.getText();
          try {
              Integer.parseInt(text.getText().trim());
          } catch (NumberFormatException e) {
              text.setText(old);
              //return false; // don't use this otherwise it won't revert the value
          }
          return true;
      }
  }
  </code></pre>