title: returning the dialog from JOptionPane.showOptionDialog
body: <p>I have created in Java swing an option dialog with the JOptionPane.showOptionDialog method. This dialog includes different buttons, and among those a Cancel button. I would like to attach a listener method to this Cancel button so that once selected, the dialog is disposed. </p>
  
  <p>My question is: how do I "retrieve" (or return) the dialog generated by the JOptionPane.showOptionDialog method?</p>