日期:2014-05-20  浏览次数:20790 次

按关闭按钮是弹出对话框,再按取消按钮
想按取消按钮时什么都不发生
我用
Java code
if(JOptionPane.showConfirmDialog(container, "是否保存?", "是否存",JOptionPane.YES_NO_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION)
          { return; }

它还是给关闭了 
  请问要怎么弄?



------解决方案--------------------
Java code

int x = JOptionPane.showConfirmDialog(null, "确认要退出么?", "退出", JOptionPane.YES_NO_OPTION);                    if (x == JOptionPane.YES_OPTION) {
        System.exit(0);
}

------解决方案--------------------
楼上正解加个if判断下。
if(x==JOptionPane.YES_OPTION)){
/////////////////////////
}
else{
////////////////////////
}
------解决方案--------------------
Java code

int x = JOptionPane.showConfirmDialog(null, "确认要退出么?", "退出",
                    JOptionPane.YES_NO_OPTION);
            if (x == JOptionPane.YES_OPTION) {
                System.exit(0);
            }