This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
You just have to catch the exception, and try again.
Another nicer option is to use a custom "NumericTextField" class in an input dialog; the NumericTextField class will only accept well-formed numbers, and your "OK" button would be greyed out otherwise. This is not terribly hard to do, but it's probably something that needs to wait until you get a bit more experience.