The confirm dialog box is not recognizing the no option. It prints yes no matter what i press. Can anyone help?
if(e.getSource()==b5)
{
int db=0;
JOptionPane.showConfirmDialog(null, "Exit this
screen?","Exit",JOptionPane.YES_NO_OPTION);
if(db==JOptionPane.NO_OPTION)
{
System.out.println("no");
}
else if(db==JOptionPane.YES_OPTION)
{
System.out.println("yes");
}
}
You havent assign JOptionPane return value to db, it should be
db = JOptionPane.showConfirmDialog(null, "Exit this screen", Exit",JOptionPane.YES_NO_OPTION);