PatchEdit.reassignAction.setEnabled(true);
    protected void InitLibraryFrame() {        //...Create the GUI and put it in the window...        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {            public void internalFrameClosing(InternalFrameEvent e) {                if (!changed) return;                                int i;                javax.swing.JInternalFrame[] jList =PatchEdit.desktop.getAllFrames();                                for (int j=0;j<jList.length;j++) {                    if (jList[j] instanceof BankEditorFrame) {                        for (i=0;i<myModel.performanceList.size();i++)                            if (((BankEditorFrame)(jList[j])).bankData==((Performance)myModel.performanceList.get(i)).getPatch())                            { 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.performanceList.size();i++)                            if (((PatchEditorFrame)(jList[j])).p==((Patch)(myModel.performanceList.get(i))))                            { jList[j].moveToFront();                              try{jList[j].setSelected(true);                              jList[j].setClosed(true); }catch (Exception e1){}                              break;}                    }                }                                if (JOptionPane.showConfirmDialog(null,"This Performance may contain unsaved data.\nSave before closing?","Unsaved Data",JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) return;                                if (getTitle().startsWith("Unsaved Performance")) {                    javax.swing.JFileChooser fc2=new javax.swing.JFileChooser();                    javax.swing.filechooser.FileFilter type1 = new ExtensionFilter("PatchEdit Performance Files",".perflib");                                        fc2.addChoosableFileFilter(type1);                    fc2.setFileFilter(type1);                                        int returnVal = fc2.showSaveDialog(null);                                        if (returnVal == javax.swing.JFileChooser.APPROVE_OPTION) {                        File file = fc2.getSelectedFile();                                                try {                            if (!file.getName().toUpperCase().endsWith(".PERFLIB"))                                file=new File(file.getPath()+".perflib");                                                        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)                {};            }                        public void internalFrameOpened(InternalFrameEvent e)            {}                        public void internalFrameActivated(InternalFrameEvent e) {                PatchEdit.receiveAction.setEnabled(true);                PatchEdit.pasteAction.setEnabled(true);                PatchEdit.importAction.setEnabled(true);                PatchEdit.importAllAction.setEnabled(true);                PatchEdit.newPatchAction.setEnabled(true);                                if (table.getRowCount()>0) {                    PatchEdit.saveAction.setEnabled(true);                    PatchEdit.menuSaveAs.setEnabled(true);                    PatchEdit.searchAction.setEnabled(true);                    PatchEdit.transferPerformanceAction.setEnabled(true);                }                                if (table.getRowCount()>1) {                    PatchEdit.sortAction.setEnabled(true);                    PatchEdit.dupAction.setEnabled(true);                    PatchEdit.crossBreedAction.setEnabled(true);                }                                if (table.getSelectedRowCount()>0) {                    PatchEdit.extractAction.setEnabled(true);                    PatchEdit.sendAction.setEnabled(true);                    PatchEdit.playAction.setEnabled(true);                    PatchEdit.storeAction.setEnabled(true);                                        Patch myPatch=((Performance)myModel.performanceList.get(table.getSelectedRow())).getPatch();                    try{                        // look, if the driver for the selected patch brings his own editor                        myPatch.getDriver().getClass().getDeclaredMethod("editPatch", new Class[]{myPatch.getClass()});                        // since the call didn't throw an exception, the driver implements the method itself                        PatchEdit.editAction.setEnabled(true);                    }                    catch(NoSuchMethodException ex) {                        // oh, the driver has no own editor. Is it a bank driver?                        if (myPatch.getDriver() instanceof BankDriver) {                            // for a bankDriver is it ok, since the universal bankEditor works                            PatchEdit.editAction.setEnabled(true);                        }                        else {                            // don't allow editing                            PatchEdit.editAction.setEnabled(false);                        }                    };                                        PatchEdit.cutAction.setEnabled(true);                    PatchEdit.copyAction.setEnabled(true);                    PatchEdit.deleteAction.setEnabled(true);                    PatchEdit.exportAction.setEnabled(true);                }                            }                        public void internalFrameClosed(InternalFrameEvent e)            {}                        public void internalFrameDeactivated(InternalFrameEvent e) {                PatchEdit.receiveAction.setEnabled(false);                PatchEdit.extractAction.setEnabled(false);                PatchEdit.sendAction.setEnabled(false);                PatchEdit.playAction.setEnabled(false);                PatchEdit.storeAction.setEnabled(false);                PatchEdit.editAction.setEnabled(false);                PatchEdit.saveAction.setEnabled(false);                PatchEdit.menuSaveAs.setEnabled(false);                PatchEdit.sortAction.setEnabled(false);                PatchEdit.searchAction.setEnabled(false);                PatchEdit.dupAction.setEnabled(false);                PatchEdit.cutAction.setEnabled(false);                PatchEdit.copyAction.setEnabled(false);                PatchEdit.pasteAction.setEnabled(false);                PatchEdit.deleteAction.setEnabled(false);                PatchEdit.importAction.setEnabled(false);                PatchEdit.importAllAction.setEnabled(false);                PatchEdit.exportAction.setEnabled(false);                PatchEdit.newPatchAction.setEnabled(false);                PatchEdit.crossBreedAction.setEnabled(false);                PatchEdit.transferPerformanceAction.setEnabled(false);            }                        public void internalFrameDeiconified(InternalFrameEvent e)            {}                        public void internalFrameIconified(InternalFrameEvent e)            {}                    });                myModel = new PerformanceListModel(changed);        table = new DNDLibraryTable(myModel);        table2=table;                rowEditor=new PerformanceTableCellEditor(table);                table.setPreferredScrollableViewportSize(new java.awt.Dimension(500, 70));        table.addMouseListener(new java.awt.event.MouseAdapter() {            public void mousePressed(MouseEvent e) {                if(e.isPopupTrigger()) {                    PatchEdit.menuPatchPopup.show(table2, e.getX(), e.getY());                    table2.setRowSelectionInterval(                    table2.rowAtPoint(new java.awt.Point(e.getX(),e.getY())),                    table2.rowAtPoint(new java.awt.Point(e.getX(),e.getY()))                    );                }            }                        public void mouseReleased(MouseEvent e) {                if(e.isPopupTrigger()) {                    PatchEdit.menuPatchPopup.show(table2, e.getX(), e.getY());                    table2.setRowSelectionInterval(                    table2.rowAtPoint(new java.awt.Point(e.getX(),e.getY())),                    table2.rowAtPoint(new java.awt.Point(e.getX(),e.getY()))                    );                }            }                        public void mouseClicked(MouseEvent e) {                if(e.getClickCount()==2) {                    PlaySelectedPatch();                }            }        });                //Create the scroll  pane and add the table to it.        final javax.swing.JScrollPane scrollPane = new javax.swing.JScrollPane(table);        DNDViewport myviewport=new DNDViewport();        scrollPane.setViewport(myviewport);        myviewport.setView(table);        scrollPane.getVerticalScrollBar().addMouseListener(new java.awt.event.MouseAdapter() {            public void mousePressed(MouseEvent e)            {}                        public void mouseReleased(MouseEvent e) {                myModel.fireTableDataChanged();            }        });                //Add the scroll pane to this window.        javax.swing.JPanel statusPanel=new javax.swing.JPanel();        statusBar=new javax.swing.JLabel(myModel.performanceList.size()+" Patches");        statusPanel.add(statusBar);                getContentPane().setLayout(new java.awt.BorderLayout());        getContentPane().add(scrollPane, java.awt.BorderLayout.CENTER);        getContentPane().add(statusPanel, java.awt.BorderLayout.SOUTH);                javax.swing.table.TableColumn column = null;        column = table.getColumnModel().getColumn(0); // Synth        column.setPreferredWidth(50);        column = table.getColumnModel().getColumn(1); // Type        column.setPreferredWidth(50);        column = table.getColumnModel().getColumn(2); // Patch Name        column.setPreferredWidth(100);        column = table.getColumnModel().getColumn(3); //Bank Number        column.setPreferredWidth(50);                column.setCellEditor(rowEditor); // Set the special pop-up Editor for Bank numbers                column = table.getColumnModel().getColumn(4); //Patch Number        column.setPreferredWidth(50);                column.setCellEditor(rowEditor); // Set the special pop-up Editorfor Patch Numbers                column = table.getColumnModel().getColumn(5); //Comment        column.setPreferredWidth(200);                //...Then set the window size or call pack...        setSize(600,300);                //Set the window's location.        setLocation(xOffset*openFrameCount, yOffset*openFrameCount);                this.addFocusListener(new java.awt.event.FocusListener() {            public void focusGained(java.awt.event.FocusEvent e) {                // System.out.println ("Focus Gained");            }                        public void focusLost(java.awt.event.FocusEvent e) {                //System.out.println ("Focus Lost");            }                    });                table.getModel().addTableModelListener( new javax.swing.event.TableModelListener() {            public void tableChanged(javax.swing.event.TableModelEvent e) {                statusBar.setText(myModel.performanceList.size()+" Patches");                if (((PerformanceListModel)e.getSource()).getRowCount()>0) {                    PatchEdit.saveAction.setEnabled(true);                    PatchEdit.menuSaveAs.setEnabled(true);                    PatchEdit.searchAction.setEnabled(true);                    PatchEdit.exportAction.setEnabled(true);                    PatchEdit.transferPerformanceAction.setEnabled(true);                }                                if (((PerformanceListModel)e.getSource()).getRowCount()>1) {                    PatchEdit.sortAction.setEnabled(true);                    PatchEdit.dupAction.setEnabled(true);                    PatchEdit.crossBreedAction.setEnabled(true);                }            }        }        );                table.getSelectionModel().addListSelectionListener(new javax.swing.event.ListSelectionListener() {            public void valueChanged(javax.swing.event.ListSelectionEvent e) {                //System.out.println ("ValueChanged"+((ListSelectionModel)e.getSource ()).getMaxSelectionIndex ());                if (((javax.swing.ListSelectionModel)e.getSource()).getMaxSelectionIndex()>=0) {                    PatchEdit.extractAction.setEnabled(true);                    PatchEdit.sendAction.setEnabled(true);                    PatchEdit.playAction.setEnabled(true);                    PatchEdit.storeAction.setEnabled(true);                                        Patch myPatch=((Performance)myModel.performanceList.get(table.getSelectedRow())).getPatch();                    try{                        myPatch.getDriver().getClass().getDeclaredMethod("editPatch", new Class[]{myPatch.getClass()});                        PatchEdit.editAction.setEnabled(true);                    }                    catch(NoSuchMethodException ex) {                        if (myPatch.getDriver() instanceof BankDriver)                            PatchEdit.editAction.setEnabled(true);                        else                            PatchEdit.editAction.setEnabled(false);                    };                                        PatchEdit.copyAction.setEnabled(true);                    PatchEdit.cutAction.setEnabled(true);                    PatchEdit.deleteAction.setEnabled(true);                    PatchEdit.exportAction.setEnabled(true);                }                                else {                    PatchEdit.extractAction.setEnabled(false);                    PatchEdit.sendAction.setEnabled(false);                    PatchEdit.playAction.setEnabled(false);                    PatchEdit.storeAction.setEnabled(false);                    PatchEdit.editAction.setEnabled(false);                    PatchEdit.copyAction.setEnabled(false);                    PatchEdit.cutAction.setEnabled(false);                    PatchEdit.deleteAction.setEnabled(false);                }            }        });    }