croucherj3
Programmer
Hi, I am having problems with the following code. It works okay if I use the mouse to select the Yes/No option from the dialog box. However, if I use the Tab/Enter keys to select No, the "E statement is always displayed when n is tested. Any ideas why this only works with the mouse?
Thanks for your help,
John
Athens, OH
============================================================
import javax.swing.*;
class DemoDialog2
{
public static void main(String[] args)
{
int n = JOptionPane.showConfirmDialog(
null, "Do you like green eggs and ham?",
"An Inane Question",
JOptionPane.YES_NO_OPTION);
if (n == JOptionPane.YES_OPTION)
System.out.println("E else
if (n == JOptionPane.NO_OPTION)
System.out.println("Me neither!"
System.exit(0);
}
}
Thanks for your help,
John
Athens, OH
============================================================
import javax.swing.*;
class DemoDialog2
{
public static void main(String[] args)
{
int n = JOptionPane.showConfirmDialog(
null, "Do you like green eggs and ham?",
"An Inane Question",
JOptionPane.YES_NO_OPTION);
if (n == JOptionPane.YES_OPTION)
System.out.println("E else
if (n == JOptionPane.NO_OPTION)
System.out.println("Me neither!"
System.exit(0);
}
}