static int getPreferredHeight(@Nullable Component component, int width) {
    return component == null ? 0 : component instanceof WidthBasedLayout ? ((WidthBasedLayout)component).getPreferredHeight(width)
                                                                         : component.getPreferredSize().height;
  }
static int getPreferredHeight(@Nullable Component component, int width)