I am trying to get JOptionPane to get the input and assign it int, but I am having some problems with variable types.
I am trying something like this:
Int ans = (Integer) JOptionPane.showInputDialog(frame, "Text", JOptionPane.INFORMATION_MESSAGE, null, null, "[sample text to help input]");
But I get:
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
Which sounds logical, I can't think of another way to do this.
Thanks in advance
java int swing user-input joptionpane
kxk
source share