我JOptionPane的代码如下:获取的JOptionPane
selectedSiteName = JOptionPane.showInputDialog("Enter the name of the new site:");
这使得从一个文本框和一个确定和取消按钮的输入。我需要检测是否点击取消。
干杯。
我JOptionPane的代码如下:获取的JOptionPane
selectedSiteName = JOptionPane.showInputDialog("Enter the name of the new site:");
这使得从一个文本框和一个确定和取消按钮的输入。我需要检测是否点击取消。
干杯。
检查是否selectedSiteName == null。
如果用户单击“取消”或关闭对话框,则会出现这种情况。
请阅读JOptionPane API并按照“如何使用对话框”中的Swing turorial链接进行工作示例。
if(selectedSiteName == JOptionPane.CANCEL_OPTION)
{
}
应该工作。