New to java and having a problem getting my loop to work. program runs and stops the user from inputting anything less than zero but not stopping them from inputting anything over 1000.
Also having a problem with the NumberFormatException as i can't let user input letters either!
Once loop is working i then need to read user input in JOptionPane and pass it to a constructor in a different class.
changed my code a bit and program now stops user from inputting anything over 1000. But how do i get it to stop user from inputting letters or words?!!\
I can see a problem, I am afraid. You have got a method inside a display component which isn't part of the display. Testing whether the input is a number or not is part of your “business logic” and ought to be in a “business class”. Which isn't the opposite of economy class. You should have a method which tests whether the input is a number or not; the display class can take action, e.g. remove the entry from the text field.
There are better ways to test whether a String represents a number than catching Exceptions. You will find some suggestions in this thread from last Summer.