private static @NotNull HierarchyListener runWhenHidden(@NotNull Runnable runnable) {
    return new HierarchyListener() {
      @Override
      public void hierarchyChanged(HierarchyEvent e) {
        if (!BitUtil.isSet(e.getChangeFlags(), HierarchyEvent.DISPLAYABILITY_CHANGED)) {
          return;
        }
        Component component = e.getComponent();
        if (component.isDisplayable()) {
          return;
        }
        component.removeHierarchyListener(this);
        runnable.run();
      }
    };
  }
private static @NotNull HierarchyListener runWhenHidden(@NotNull Runnable runnable)