This example shows the use of exception throwing. It provides a version of JOptionPane that only accepts integers, converts its output to int, and reprompts if incorrect input is entered.
Here is the source code: IntegerPane.java, something to test it out, Driver.java, and documentation.