mouseInputListener = new MouseInputHandler(rootContainer);
mouseInputListener = new MouseInputHandler(rpContainer);
    public void popupMenuWillBecomeVisible(PopupMenuEvent event)    {      // Adds topWindowListener to top-level window to listener to       // ComponentEvents fired by it. We need to cancel this popup menu      // if topWindow to which this popup belongs was resized or moved.      Component invoker = popupMenu.getInvoker();      RootPaneContainer rootContainer = (RootPaneContainer) SwingUtilities                                        .getRoot(invoker);      ((Container) rootContainer).addComponentListener(topWindowListener);      // Set the glass pane to interrupt all mouse events originating in root       // container      if (mouseInputListener == null)        {	  Container glassPane = (Container) rootContainer.getGlassPane();	  glassPane.setVisible(true);	  mouseInputListener = new MouseInputHandler(rootContainer);	  glassPane.addMouseListener(mouseInputListener);	  glassPane.addMouseMotionListener(mouseInputListener);        }      // if this popup menu is a free floating popup menu,      // then by default its first element should be always selected when      // this popup menu becomes visible.       MenuSelectionManager manager = MenuSelectionManager.defaultManager();      if (manager.getSelectedPath().length == 0)        {	  // Set selected path to point to the first item in the popup menu	  MenuElement[] path = new MenuElement[2];	  path[0] = popupMenu;	  Component[] comps = popupMenu.getComponents();	  if (comps.length != 0 && comps[0] instanceof MenuElement)	    {	    path[1] = (MenuElement) comps[0];	  manager.setSelectedPath(path);        }    }  }