// InputDialog, MessageDialog, if.., String.equals
import javax.swing.*;
public class Greeting extends JOptionPane
{
public static void main(String[] args)
{
new Greeting();
}
public Greeting()
{
String answer = showInputDialog(this,"How are you today?");
if ( answer.equals("sick") )
{ showMessageDialog(this,"Sorry to hear that..."); }
else if ( answer.equals("fine") )
{ showMessageDialog(this,"Good!"); }
else
{ showMessageDialog(this,"- okay -"); }
System.exit(0);
}
}
|