title: Checking whether the text in a JTextField is a certain data type
body: <p>I am trying to write some validation code in my class for my GUI. How would I go about getting the text from a JTextField into a while statement and prompting a JOptionPane for the user to enter the necessary number(double)? To be more specific, how do I check if what I got from the JTextField is a string/string+number/anything other than a number?</p>
  <pre><code>String text=JTextField.getText();
  
  while(text.equals*a string or anything but a number*);
     JOP(&quot;Invalid input ............ etc...
  </code></pre>
  <p>If you have time, here is my GUI and my class. I am trying to do this for the rest of the methods. But the answer to the above will suffice.</p>
  <p><a href="http://www.mediafire.com/?f079i1xtihypg1b" rel="nofollow noreferrer">http://www.mediafire.com/?f079i1xtihypg1b</a></p>
  <p><a href="http://www.mediafire.com/file/f079i1xtihypg1b/FinanceGUI.java" rel="nofollow noreferrer">http://www.mediafire.com/file/f079i1xtihypg1b/FinanceGUI.java</a></p>
  <h3>Update:</h3>
  <p>This is what I have so far:</p>
  <pre><code>  //get the text entered in the amountRentText
    //JTextField and parse it to a Double
  String amtRentIn=amountRentText.getText();
  
  try{Double.parseDouble(amtRentIn);}
  catch(NumberFormatException nfe){
     while()
         amtRentIn=JOptionPane.showInputDialog(&quot;Invalid input. Please &quot;+
             &quot;enter your rent: &quot;);
   }
  
   double rent= Double.parseDouble(amtRentIn);
   fin.setRent(rent);
  </code></pre>
  <p>What do I put in the while?</p>