private static @NotNull WindowStateAdapter getAdapter(@NotNull Window window) {
    for (ComponentListener listener : window.getComponentListeners()) {
      if (listener instanceof WindowStateAdapter) {
        return (WindowStateAdapter)listener;
      }
    }
    return new WindowStateAdapter(window);
  }
private static @NotNull WindowStateAdapter getAdapter(@NotNull Window window)