另外,现在每当我点击右上角的“X”按钮时,对话框的行为就像我点击了确定(在消息上)或是(在问题上)。当用户点击 X 时,我想要 DO_Nothing。
在下面的代码中,当我单击对话框上的 X 时,它会弹出“吃!”。显然,X 正在充当“是”选项,它不应该这样做。
int c =JOptionPane.showConfirmDialog(null, "Are you hungry?", "1", JOptionPane.YES_NO_OPTION);
if(c==JOptionPane.YES_OPTION){
JOptionPane.showMessageDialog(null, "eat!", "Order",JOptionPane.PLAIN_MESSAGE);
}
else {JOptionPane.showMessageDialog(null, "ok cool", "Order",JOptionPane.PLAIN_MESSAGE);}