Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JOptionPane - showInputDialog

 
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
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change this

to this
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic