FilenameFilter type1 = new ExtensionFilter("PatchEdit Library Files",".patchlib");
FilenameFilter type1 = new ExtensionFilter("PatchEdit Library Files (*.patchlib)",".patchlib");
            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"))                {                    FileDialog fc2=new FileDialog(PatchEdit.instance);                    FilenameFilter type1 = new ExtensionFilter("PatchEdit Library Files",".patchlib");                                        fc2.setFilenameFilter(type1);		    fc2.setDirectory (PatchEdit.appConfig.getLibPath());		    fc2.show();                                        if (fc2.getDirectory() == null || fc2.getFile() == null)                    {		      File file = new File(fc2.getDirectory(), fc2.getFile());                                                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)                {};            }