I am currently working on a program which accepts a user input through the JOptionPane window. My goal is to create an if statement which validates the user input as an integer. I’ve tried the Integer.parseInt method but that just throws an exception, so I cannot display my own JOptionPane window informing the user of the mistake. I’m very new to programming and cannot think of another way to convert the string to an integer (or at least another way that works) for use in the if statement. Ideas?
Thanks!
If you are to get an integer somehow after the
JOptionPanemessage is displayed, you may want to take a look at this code which continuously prompts the user to enter a valid integer: