code: private static Window getWindowAncestor(JTextComponent component) {
          if (component == null) {
              return null;
          }
          return SwingUtilities.getWindowAncestor(component);
      }
docs: Gets the ancestor {@code Window} where the given {@code component} is contained.
  
  @param component the component.
  @return the {@code Window}, or {@code null} if the component is {@code null} or if not contained inside a {@code Window}.