Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the return value of JOptionPane

My JOptionPane code is as follows:

selectedSiteName = JOptionPane.showInputDialog("Enter the name of the new site:");

This renders out an input with a textbox and an OK and Cancel button. I need to detect if Cancel was clicked.

Cheers.

like image 399
burntsugar Avatar asked Aug 01 '09 00:08

burntsugar


1 Answers

Check if selectedSiteName == null .
This will be the case if the user clicks Cancel or closes the dialog.

like image 64
Jataro Avatar answered Oct 05 '22 14:10

Jataro