An appeal to the Java gods

<p>I’m new at java, and i had a question- how do you do a GUI output/input? like in a simple integer variable?</p>

<p>First you have to: import.javax.swing.JOptionPane;
Then to show dialog in GUI: JOptionPane.showMessageDialog(“Hello world”);
If you want to get input the structue is: String input = JOptionPane.showInputDialog(“What is your name?”);</p>

<p>Remember that JOptionPane only returns strings, so you have to parse if you want int, double, boolean, etc etc etc.</p>

<p>Sorry, didn’t see you wanted an int. Here is the full code for what you want to do:
import javax.swing.JOptionPane;
public class Parse{
public static void main(String args){
String input = JOptionPane.showInputDialog(“How old are you?”);
int age = Integer.parseInt(input);
JOptionPane.showMessageDialog(null, "Your age is: "+age);
}
}</p>

<p>// notice the “null,” that is extremely important. Don’t leave it off.</p>

<p>thank you, i was googling “how to” for like an hour</p>

<p>ok, so i tried it out today, and on the line with import javax.swing it says illegal start of expression and not a statement. on the public class Parse it says illegal start of expression. i forgot to say this, but i’m trying to get this input/output onto an existing file named public class variablepractice, in which i put all the different variables (int, double, etc.)</p>

<p>I can’t help you there :stuck_out_tongue: Sorry</p>