code: public Window getWindow ()
      {
          Component parent = getParent();
          while (!(parent instanceof Window) && parent != null) {
              parent = parent.getParent();
          }
          return (Window)parent;
      }
docs: from interface FrameManager.ManagedRoot