Dimension (Container parent) { Dimension result = new Dimension(myNameComponent.getPreferredSize()); if (myProgressComponent == null) { if (myCheckBoxComponent != null) { Dimension size = myCheckBoxComponent.getPreferredSize(); result.width += size.width + myHOffset.get(); result.height = Math.max(result.height, size.height); } if (myTagComponent != null) { Dimension size = myTagComponent.getPreferredSize(); result.width += size.width + 2 * myHOffset.get(); result.height = Math.max(result.height, size.height); } int count = myButtonComponents.size(); if (count > 0) { int visibleCount = 0; for (Component component : myButtonComponents) { if (component.isVisible()) { Dimension size = component.getPreferredSize(); result.width += size.width; result.height = Math.max(result.height, size.height); visibleCount++; } } if (visibleCount > 0) { result.width += myHOffset.get(); result.width += (visibleCount - 1) * myButtonOffset.get(); } } } else { Dimension size = myProgressComponent.getPreferredSize(); result.width += myHOffset.get() + size.width; result.height = Math.max(result.height, size.height); } for (JComponent component : myLineComponents) { if (component.isVisible()) { Dimension size = component.getPreferredSize(); result.width = Math.max(result.width, size.width); result.height += size.height; } } Dimension iconSize = myIconComponent.getPreferredSize(); result.width += iconSize.width + myHGap.get(); result.height = Math.max(result.height, iconSize.height); JBInsets.addTo(result, getInsets()); return result; }