void (Dimension preferred, Component component) { if (component != null) { Dimension size = component.getPreferredSize(); preferred.height += size.height; if (preferred.width < size.width) preferred.width = size.width; } }