returning the dialog from JOptionPane.showOptionDialog
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. 

My question is: how do I "retrieve" (or return) the dialog generated by the JOptionPane.showOptionDialog method?
returning the dialog from JOptionPane.showOptionDialog
===

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. 

My question is: how do I "retrieve" (or return) the dialog generated by the JOptionPane.showOptionDialog method?