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