Container rootContainer = (Container) SwingUtilities.getRoot(invoker); rootContainer.removeComponentListener(topWindowListener);
RootPaneContainer rootContainer = (RootPaneContainer) SwingUtilities .getRoot(invoker); ((Container) rootContainer).removeComponentListener(topWindowListener);     boolean topLevelMenu = (popupMenu.getInvoker() instanceof JMenu) && ((JMenu) popupMenu.getInvoker()) .isTopLevelMenu();  if (topLevelMenu || ! (popupMenu.getInvoker() instanceof MenuElement)) {   Container glassPane = (Container) rootContainer.getGlassPane(); glassPane.setVisible(false); glassPane.removeMouseListener(mouseInputListener); mouseInputListener = null; }
    public void popupMenuWillBecomeInvisible(PopupMenuEvent event)    {      // remove listener that listens to component events fired       // by the top - level window that this popup belongs to.      Component invoker = popupMenu.getInvoker();      Container rootContainer = (Container) SwingUtilities.getRoot(invoker);      rootContainer.removeComponentListener(topWindowListener);    }