-1

This is the code, which helps to display confirm dialog box on screen, First if statement just checks which radio button are pressed, than a confirm dialog box appears, On which there is option available , which is "ok" and "cancel". So when I click either "ok" or "Cancel" another confirm dialog box appears, which must have to show message, which shows which one is clicked, but there is an error, even if I click "ok" , it shows you pressed cancel

if (Choose == okCancel.getText() && IconChoose == NoneRadioButton.getText())
{
    int response = 
        JOptionPane.showConfirmDialog(null, txt, " Message Dialog Box", 
                                      JOptionPane.OK_CANCEL_OPTION);
}
else if (response == JOptionPane.OK_OPTION)
{
    JOptionPane.showConfirmDialog(null, "You Pressed OK ","", 
                                  JOptionPane.DEFAULT_OPTION);
}

if (response == JOptionPane.CANCEL_OPTION)
{
    JOptionPane.showConfirmDialog(null, "You Pressed CANCEL ","",
                                  JOptionPane.DEFAULT_OPTION);
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
akki0996
  • 713
  • 2
  • 6
  • 14

1 Answers1

0

try to use

 .equals() or equalsIgnoreCase();

instaed of ==

PSR
  • 39,804
  • 41
  • 111
  • 151