获取JOptionPane的返回值

bur*_*gar 9 java joptionpane

我的JOptionPane代码如下:

selectedSiteName = JOptionPane.showInputDialog("Enter the name of the new site:");
Run Code Online (Sandbox Code Playgroud)

这将使用文本框和"确定"和"取消"按钮呈现输入.我需要检测是否点击了取消.

干杯.

Jat*_*aro 14

检查selectedSiteName == null.
如果用户单击"取消"或关闭对话框,则会出现这种情况.