public static void runWhenHidden(@NotNull Component component, @NotNull Runnable runnable) {
    component.addHierarchyListener(runWhenHidden(runnable));
  }
public static void runWhenHidden(@NotNull Component component, @NotNull Runnable runnable)