title: Confirm dialog box in swing with two buttons
body: <p>Following is my swing program code</p>
  
  <pre><code>import javax.swing.*;  
  import java.awt.event.*;  
  public class OptionPaneExample extends WindowAdapter{  
  JFrame f;  
  OptionPaneExample(){  
      f=new JFrame();   
      f.addWindowListener(this);  
      f.setSize(300, 300);  
      f.setLayout(null);  
      f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);  
      f.setVisible(true);  
  }  
  public void windowClosing(WindowEvent e) {  
      int a=JOptionPane.showConfirmDialog(f,"Are you sure?");  
  if(a==JOptionPane.YES_OPTION){  
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
  }  
  }  
  public static void main(String[] args) {  
      new  OptionPaneExample();  
  }     
  } 
  </code></pre>
  
  <p>In output i want only two buttons Yes and No. But in output i'm getting cancel button. How to remove that please let me know.</p>
  
  <p><a href="https://i.stack.imgur.com/i6CTy.png" rel="nofollow noreferrer">I'm getting this output. But i want only two buttons Yes and No.</a></p>
  
  <p><img src="https://i.stack.imgur.com/i6CTy.png"></p>