Trying to transfer a console program to a GUI program is not an easy task if you've never made a GUI program before. You need to learn about event-driven programming. I suggest you have a look at the Swing tutorials
Some tips though. It you want a "semi-gui" program. You can just use JOptionPane
s for the input. Say you want to get an number input. You would do something like this
String numberString = JOptionPane.showInputDialog(null, "Enter a Number");
int number = Integer.parseInteger(numberString);
once you do the first line, an input pane automatically pops up. asking for an input. The result is a String, so you have to parse it to get a number.
Also if you just want to diplay a message, just use
JOptionPane.showMessageDialog(null, message);
You can do that do display some result. In the above case when you just want to show a message, you don't need to make it equal to anything. So instead of the System.out.println()
s, you can just use the JOPtionpane.showMesageDialog()
and instead of reader.readLine()
, you would use JOptionPane.showInputDialog()
Try it out and come back if you're stuck.
Also see the documentation for JOptionPane to see what other possible popup dialogs there are.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…