@NotNull
    private static Dimension getPreferredSize(@NotNull JComponent component) {
      return component.isVisible() ? component.getPreferredSize() : new Dimension();
    }
@NotNull
    private static Dimension getPreferredSize(@NotNull JComponent component)