我正在使用此代码来确认用户在单击 JFrame 的红十字关闭按钮时是否要退出(右上角)
Object[] options = {"Quit, My Computing Fellow", "No, I want to Work more"};
int Answer = JOptionPane.showOptionDialog(null, "What would you like to do? ","Quit:Continue", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
null, options,options[1]);
if(Answer == JOptionPane.YES_OPTION){
System.exit(0);
}
else if (Answer == JOptionPane.CANCEL_OPTION) {
return;
}
但问题是如果用户单击 CANCEL_OPTION 框架完全关闭,但我希望用户仍然打开框架并且不允许框架关闭。指导我如果我犯了错误或其他什么?