import javax.swing.JOptionPane;
public class inputTest
{

public static void main(String [] args)
   {
   int x = 0;
   String userInput;
   boolean inputIsGood = false;
   
do {   
   userInput = JOptionPane.showInputDialog("Enter a number");
   try
       {
       x = Integer.parseInt( userInput );
	   inputIsGood = true; // only way out of do...while loop	  
       }
     catch (NumberFormatException e)
       {
	   System.out.println("Format Error: " + e.toString()); 
	   e.printStackTrace(); 
	   }	   	   
     catch (Exception e)
       {
	   System.out.println("Error: " + e.toString());  
	   }	   	   
	  
} while (inputIsGood == false);
  
   System.out.println("X is " +  x);
   System.exit(0);
   } // end main

} // end class
