Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JOptionPane - showInputDialog  RSS feed

 
c york
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having problems with displaying the second input dialog. Can someone help me!

import javax.swing.JOptionPane;

public class GetInputFromKeyboardJOptionPane{

public static void main(String[] args) {
String name = "";

name = JOptionPane.showInputDialog("Please enter your name");
String msg = "Hello " + name + "!";
JOptionPane.showMessageDialog(null, msg);

String age = "";
int ageint = Integer.parseInt(age);

age = JOptionPane.showInputDialog("Please enter your age");
if (ageint > 100){
String msg2 = "Hello " + name + "You are old!";
JOptionPane.showMessageDialog(null, msg2);
}else{
String msg3 = "Hello " + name + "You are young!";
JOptionPane.showMessageDialog(null, msg3);
}

}
}
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change this

to this
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!