public static @Nullable Window getWindow(@Nullable Component component) {
    return component == null ? null :
           component instanceof Window ? (Window)component :
           SwingUtilities.getWindowAncestor(component);
  }
public static @Nullable Window getWindow(@Nullable Component component)