/**
  * Installs the necessary Listeners on the parent <code>Window</code>, if there is one.
  *
  * <p>This takes the parent so that cleanup can be done from <code>removeNotify</code>, at which
  * point the parent hasn't been reset yet.
  *
  * @param parent The parent of the JRootPane
  */
 private void installWindowListeners(JRootPane root, Component parent) {
   if (parent instanceof Window) {
     window = (Window) parent;
   } else {
     window = SwingUtilities.getWindowAncestor(parent);
   }
   if (window != null) {
     if (mouseInputListener == null) {
       mouseInputListener = createWindowMouseInputListener(root);
     }
     window.addMouseListener(mouseInputListener);
     window.addMouseMotionListener(mouseInputListener);
   }
 }