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