Did you read JOptionPane
's documentation?
There are two ways to use it. One way is to use the various static methods that already return the user's choice or input.
The other way is a direct use (mentioned in the documentation). Once you created a JOptionPane
, you can configure it with various setX
methods. Then you retrieve a JDialog instance, as you already did. After that dialog is close, you can retrieve the user's choice or input with
optionPane.getValue()
or
optionPane.getInputValue()