Program: 61944
Project: 61944
Buggy source:
private void createContextMenu(){
  final JPopupMenu contextPopupMenu=new JPopupMenu();
  final JMenuItem removeMenuItem=new JMenuItem(translate("String_Node_Str"));
  removeMenuItem.addActionListener(this);
  removeMenuItem.setActionCommand(ACTION_REMOVE_ITEM);
  final JMenuItem exportSelectionMenuItem=new JMenuItem(translate("String_Node_Str"));
  exportSelectionMenuItem.setActionCommand(MainFrameRibbon.ACTION_EXPORT_SEL);
  exportSelectionMenuItem.addActionListener(this);
  contextPopupMenu.add(exportSelectionMenuItem);
  final JMenuItem replaceImageSelectionMenuItem=new JMenuItem(translate("String_Node_Str"));
  replaceImageSelectionMenuItem.setActionCommand(ACTION_REPLACE_IMAGE);
  replaceImageSelectionMenuItem.addActionListener(this);
  contextPopupMenu.add(replaceImageSelectionMenuItem);
  final JMenuItem replaceBinarySelectionMenuItem=new JMenuItem(translate("String_Node_Str"));
  replaceBinarySelectionMenuItem.setActionCommand(ACTION_REPLACE_BINARY);
  replaceBinarySelectionMenuItem.addActionListener(this);
  contextPopupMenu.add(replaceBinarySelectionMenuItem);
  final JMenuItem closeSelectionMenuItem=new JMenuItem(translate("String_Node_Str"));
  closeSelectionMenuItem.setActionCommand(ACTION_CLOSE_SWF);
  closeSelectionMenuItem.addActionListener(this);
  contextPopupMenu.add(closeSelectionMenuItem);
  contextPopupMenu.add(removeMenuItem);
  tagTree.addMouseListener(new MouseAdapter(){
    @Override public void mouseClicked(    MouseEvent e){
      if (SwingUtilities.isRightMouseButton(e)) {
        int row=tagTree.getClosestRowForLocation(e.getX(),e.getY());
        int[] selectionRows=tagTree.getSelectionRows();
        if (!Helper.contains(selectionRows,row)) {
          tagTree.setSelectionRow(row);
        }
        TreePath[] paths=tagTree.getSelectionPaths();
        if (paths == null || paths.length == 0) {
          return;
        }
        boolean allSelectedIsTag=true;
        for (        TreePath treePath : paths) {
          Object tagObj=treePath.getLastPathComponent();
          if (tagObj instanceof TagNode) {
            Object tag=((TagNode)tagObj).tag;
            if (!(tag instanceof Tag)) {
              allSelectedIsTag=false;
              break;
            }
          }
        }
        replaceImageSelectionMenuItem.setVisible(false);
        replaceBinarySelectionMenuItem.setVisible(false);
        if (paths.length == 1) {
          Object tagObj=paths[0].getLastPathComponent();
          if (tagObj instanceof TagNode) {
            Object tag=((TagNode)tagObj).tag;
            if (tag instanceof ImageTag && ((ImageTag)tag).importSupported()) {
              replaceImageSelectionMenuItem.setVisible(true);
            }
            if (tag instanceof DefineBinaryDataTag) {
              replaceBinarySelectionMenuItem.setVisible(true);
            }
          }
          if (tagObj instanceof SWFRoot) {
            closeSelectionMenuItem.setVisible(true);
          }
        }
        removeMenuItem.setVisible(allSelectedIsTag);
        contextPopupMenu.show(e.getComponent(),e.getX(),e.getY());
      }
    }
  }
);
}

Fixed version (ground truth):
private void createContextMenu(){
  final JPopupMenu contextPopupMenu=new JPopupMenu();
  final JMenuItem removeMenuItem=new JMenuItem(translate("String_Node_Str"));
  removeMenuItem.addActionListener(this);
  removeMenuItem.setActionCommand(ACTION_REMOVE_ITEM);
  final JMenuItem exportSelectionMenuItem=new JMenuItem(translate("String_Node_Str"));
  exportSelectionMenuItem.setActionCommand(MainFrameRibbon.ACTION_EXPORT_SEL);
  exportSelectionMenuItem.addActionListener(this);
  contextPopupMenu.add(exportSelectionMenuItem);
  final JMenuItem replaceImageSelectionMenuItem=new JMenuItem(translate("String_Node_Str"));
  replaceImageSelectionMenuItem.setActionCommand(ACTION_REPLACE_IMAGE);
  replaceImageSelectionMenuItem.addActionListener(this);
  contextPopupMenu.add(replaceImageSelectionMenuItem);
  final JMenuItem replaceBinarySelectionMenuItem=new JMenuItem(translate("String_Node_Str"));
  replaceBinarySelectionMenuItem.setActionCommand(ACTION_REPLACE_BINARY);
  replaceBinarySelectionMenuItem.addActionListener(this);
  contextPopupMenu.add(replaceBinarySelectionMenuItem);
  final JMenuItem closeSelectionMenuItem=new JMenuItem(translate("String_Node_Str"));
  closeSelectionMenuItem.setActionCommand(ACTION_CLOSE_SWF);
  closeSelectionMenuItem.addActionListener(this);
  contextPopupMenu.add(closeSelectionMenuItem);
  contextPopupMenu.add(removeMenuItem);
  tagTree.addMouseListener(new MouseAdapter(){
    @Override public void mouseClicked(    MouseEvent e){
      if (SwingUtilities.isRightMouseButton(e)) {
        int row=tagTree.getClosestRowForLocation(e.getX(),e.getY());
        int[] selectionRows=tagTree.getSelectionRows();
        if (!Helper.contains(selectionRows,row)) {
          tagTree.setSelectionRow(row);
        }
        TreePath[] paths=tagTree.getSelectionPaths();
        if (paths == null || paths.length == 0) {
          return;
        }
        boolean allSelectedIsTag=true;
        for (        TreePath treePath : paths) {
          Object tagObj=treePath.getLastPathComponent();
          if (tagObj instanceof TagNode) {
            Object tag=((TagNode)tagObj).tag;
            if (!(tag instanceof Tag)) {
              allSelectedIsTag=false;
              break;
            }
          }
 else {
            allSelectedIsTag=false;
          }
        }
        replaceImageSelectionMenuItem.setVisible(false);
        replaceBinarySelectionMenuItem.setVisible(false);
        if (paths.length == 1) {
          Object tagObj=paths[0].getLastPathComponent();
          if (tagObj instanceof TagNode) {
            Object tag=((TagNode)tagObj).tag;
            if (tag instanceof ImageTag && ((ImageTag)tag).importSupported()) {
              replaceImageSelectionMenuItem.setVisible(true);
            }
            if (tag instanceof DefineBinaryDataTag) {
              replaceBinarySelectionMenuItem.setVisible(true);
            }
          }
          if (tagObj instanceof SWFRoot) {
            closeSelectionMenuItem.setVisible(true);
          }
        }
        removeMenuItem.setVisible(allSelectedIsTag);
        contextPopupMenu.show(e.getComponent(),e.getX(),e.getY());
      }
    }
  }
);
}