@NotNull
  private static Dimension getPreferredSize(@Nullable Component component) {
    return component != null && component.isVisible() ? component.getPreferredSize() : new Dimension();
  }
@NotNull
  private static Dimension getPreferredSize(@Nullable Component component)