save (file);
if (file.exists())  if (JOptionPane.showConfirmDialog(null,"Are you sure?","File Exists",JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) return;  save(file);
            public void internalFrameClosing (InternalFrameEvent e)            {               	        if (!changed) return;                int i;	        JInternalFrame[] jList =PatchEdit.desktop.getAllFrames ();  	        for (int j=0;j<jList.length;j++)		 {	               if (jList[j] instanceof BankEditorFrame) 		     {    		        for (i=0;i<myModel.PatchList.size();i++)	                     if (((BankEditorFrame)(jList[j])).bankData==((Patch)(myModel.PatchList.get(i))))			     { jList[j].moveToFront();			     try{jList[j].setSelected(true);			     jList[j].setClosed(true); }catch (Exception e1){}			       break;}		     }		    		    if (jList[j] instanceof PatchEditorFrame) 		     {    		        for (i=0;i<myModel.PatchList.size();i++)	                     if (((PatchEditorFrame)(jList[j])).p==((Patch)(myModel.PatchList.get(i))))			     { jList[j].moveToFront();			     try{jList[j].setSelected(true);			     jList[j].setClosed(true); }catch (Exception e1){}			       break;}		     }		 }	                      if (JOptionPane.showConfirmDialog (null,"This Library may contain unsaved data.\nSave before closing?","Delete Duplicate Patches",JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) return;                if (getTitle ().startsWith ("Unsaved Library"))                {                    JFileChooser fc2=new JFileChooser ();                    javax.swing.filechooser.FileFilter type1 = new ExtensionFilter ("PatchEdit Library Files",".patchlib");                    fc2.addChoosableFileFilter (type1);                    fc2.setFileFilter (type1);                    int returnVal = fc2.showSaveDialog (null);                    if (returnVal == JFileChooser.APPROVE_OPTION)                    {                        File file = fc2.getSelectedFile ();                        try                        {                            if (!file.getName ().toUpperCase ().endsWith (".PATCHLIB"))                                file=new File (file.getPath ()+".patchlib");                            if (file.isDirectory ())                            { ErrorMsg.reportError ("Error", "Can not save over a directory");                              return;                            }                            if (file.exists ())                                if (JOptionPane.showConfirmDialog (null,"Are you sure?","File Exists",JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) return;                                                        save (file);                        } catch (Exception ex)                        {                            ErrorMsg.reportError ("Error", "Error saving File",ex);                        }                                            }                    return;                }                                try                {                    save ();                } catch (Exception ex)                {};            }