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

急有关SWING的问题!!
public   MiniDrawPad()                 //构造函数
    {    
      super( "Drawing   Pad ");
      addWindowListener(
                new   WindowAdapter(){
                      public   void   windowClosing(WindowEvent   e)
                      {                 int   ok;
                                    ok=JOptionPane.showConfirmDialog(null, "文件未保存,单击 '是 '保存,单击‘否’退出 ", "警告 ",JOptionPane.YES_NO_CANCEL_OPTION   );
                                    if(ok==JOptionPane.YES_OPTION){saveFile();}
                      if(ok==JOptionPane.NO_OPTION) {System.exit(0);}
                      else{//这里该加什么代码?}}});
public   MiniDrawPad()   //构造函数  
{   addWindowListener(  
new   WindowAdapter(){  
public   void   windowClosing(WindowEvent   e)  
{   int   ok;  
ok=JOptionPane.showConfirmDialog(null, "文件未保存,单击´是´保存,单击‘否’退出,取消返回程序 ", "警告 ",JOptionPane.YES_NO_CANCEL_OPTION   );  
if(ok==JOptionPane.YES_OPTION){saveFile();}  
if(ok==JOptionPane.NO_OPTION)   {System.exit(0);}  
else{????}}});  


是空语句的话程序消失但没有停止。我想实现的是点CANCEL_OPTION返回到当前的状态而不是退出。请高手指点下又什么语句

------解决方案--------------------
只判断 yes 和no 就可以了
if(ok==JOptionPane.YES_OPTION){saveFile();}
if(ok==JOptionPane.NO_OPTION) {System.exit(0);}

else就不要写 不做处理 CANCEL 就可以了