JOptionPane

Know how to create input and output dialogs using the JOptionPane class.



Integer.parseInt

Know that values in String variables are not usable in calculations and know how to convert them to numeric values.

If you want a pop up to give the user a message use:
JOptionPane.showMessageDialog(null, “This is a message");
Don’t forget the null, and that your message needs to be in quotes.

If you want to get an answer from the user, you need an input dialog:
String answer = JOptionPane.showInputDialog(“Question?”);
Remember, you must catch the user’s answer in a String, otherwise you won't know what they typed.

Because the answer is always placed in a String, you sometimes need to convert it to a number so you can do calculations with it. Use code like this to convert it to an integer:
int number = Integer.parseInt(answer);
or code like this to convert it to a decimal:
double decimal = Double.parseDouble(answer);