JOptionPane
807599Mar 23 2007 — edited Mar 23 2007I am not sure if it is the location of the brackets for the if, else blocks. I keep getting the else without if error on this one. Any ideas or examples that I could look at to answer my own question. Thanks in advance. I searched the forums but did not find anything that made sense to me yet. This is in NetBeans by the way.
import javax.swing.JOptionPane;
/*
* InputFromKeyboardJOptionPane.java
*
* Created on January 24, 2007, 10:46 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
/**
*
* @author sang
*/
public class InputFromKeyboardJOptionPaneProject {
/** Creates a new instance of InputFromKeyboardJOptionPane */
public InputFromKeyboardJOptionPaneProject() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String name = "";
name=JOptionPane.showInputDialog("Please enter your name");
String age = "";
age=JOptionPane.showInputDialog("Please enter your age");
if(age > 100){
JOptionPane.showMessageDialog(null, msg);
String msg = "Hello" + name + "You are old!";
}
else
JOptionPane.showMessageDialog(null, msg);
String msg = "Hello" + name + "You are young!";
}
}