private static @Nullable JRootPane getRootPane(@Nullable Window window) {
    if (window instanceof RootPaneContainer container) {
      return container.getRootPane();
    }
    return null;
  }
private static @Nullable JRootPane getRootPane(@Nullable Window window)