How to call JOptionPane with only Yes/No options?

java, joptionpane, swing

Solution

Yes. it is possible.

int result = JOptionPane.showConfirmDialog(null, 
   "Are you sure you wish to exit application?",null, JOptionPane.YES_NO_OPTION);
if(result == JOptionPane.YES_OPTION) {
    System.exit(0);
} 

Problem

Is it possible to call a confirmation dialog, that would have ONLY `YES` and `NO` options (without the CANCEL option)? ``` JOptionPane.showConfirmDialog(null, "Are you sure?") ``` Gives three options, but I need only two.

Original source

Related problems