void (Container parent) { Insets insets = parent.getInsets(); int width = parent.getWidth() - insets.left - insets.right; int y = insets.top; int count = parent.getComponentCount(); for (int i = 0; i < count; i++) { Component component = parent.getComponent(i); if (!component.isVisible()) { continue; } Dimension size = component.getPreferredSize(); int componentWidth; if (myFillComponents.contains(component)) { componentWidth = width; } else { componentWidth = Math.min(width, size.width); Integer maxWidth = myMaxComponents.get(component); if (maxWidth != null) { componentWidth = Math.min(componentWidth, maxWidth); } } component.setBounds(insets.left, y, componentWidth, size.height); y += size.height + myOffset; } }