这是有助于在屏幕上显示确认对话框的代码,首先 if 语句仅检查按下了哪个单选按钮,然后出现确认对话框,其中有可用选项,即“确定”和“取消”。因此,当我单击“确定”或“取消”时,会出现另一个确认对话框,该对话框必须显示消息,显示单击了哪个,但是有错误,即使单击“确定”,它也会显示您按下取消
if (Choose == okCancel.getText() && IconChoose == NoneRadioButton.getText())
{
int response =
JOptionPane.showConfirmDialog(null, txt, " Message Dialog Box",
JOptionPane.OK_CANCEL_OPTION);
}
else if (response == JOptionPane.OK_OPTION)
{
JOptionPane.showConfirmDialog(null, "You Pressed OK ","",
JOptionPane.DEFAULT_OPTION);
}
if (response == JOptionPane.CANCEL_OPTION)
{
JOptionPane.showConfirmDialog(null, "You Pressed CANCEL ","",
JOptionPane.DEFAULT_OPTION);
}