if (evt.BUTTON3 == evt.getButton()||evt.BUTTON2 == evt.getButton()) { try{  Object p = modelTree.getClosestPathForLocation(evt.getX(), evt.getY()).getLastPathComponent(); if (p instanceof AbstractDescriptionNode){ AbstractDescriptionNode ADN = (AbstractDescriptionNode)p; currentContextObject=p; ContextMenu = ADN.getContextMenu(); JMenuItem Desc = new JMenuItem(); Desc.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { DescriptionMenuClicked(evt); } }); Desc.setText("Description"); ContextMenu.add(Desc); ContextMenu.setLocation(evt.getPoint()); ContextMenu.setVisible(true);  } } catch(Exception e){System.out.println(e);} } else {
if (evt.BUTTON3 == evt.getButton()||evt.BUTTON2 == evt.getButton()) { try{  Object p = modelTree.getClosestPathForLocation(evt.getX(), evt.getY()).getLastPathComponent(); if (p instanceof AbstractDescriptionNode){ AbstractDescriptionNode adn = (AbstractDescriptionNode)p; currentContextObject = p; contextMenu = adn.getContextMenu(); JMenuItem desc = new JMenuItem(); desc.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { DescriptionMenuClicked(evt); } }); desc.setText("Description"); contextMenu.add(desc); contextMenu.show( this, evt.getX(), evt.getY() ); } } catch(Exception e){System.out.println(e);} } else {
    private void modelTreeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_modelTreeMouseClicked        if (evt.BUTTON3 == evt.getButton()||evt.BUTTON2 == evt.getButton())        {          try{            //Object p =modelTree.getSelectionPath().getLastPathComponent();            Object p = modelTree.getClosestPathForLocation(evt.getX(), evt.getY()).getLastPathComponent();            if (p instanceof AbstractDescriptionNode){               AbstractDescriptionNode ADN = (AbstractDescriptionNode)p;               currentContextObject=p;               ContextMenu = ADN.getContextMenu();               JMenuItem Desc = new JMenuItem();               Desc.addMouseListener(new java.awt.event.MouseAdapter() {            public void mouseClicked(java.awt.event.MouseEvent evt) {                DescriptionMenuClicked(evt);            }            });               Desc.setText("Description");               ContextMenu.add(Desc);               ContextMenu.setLocation(evt.getPoint());               ContextMenu.setVisible(true);                                          }          }          catch(Exception e){System.out.println(e);}        }        else        {            displayDescription(modelTree.getSelectionPath().getLastPathComponent());        }            }//GEN-LAST:event_modelTreeMouseClicked