Dimension (Container parent) { Dimension baseSize = myBaseComponent.getPreferredSize(); int width = baseSize.width; if (myProgressComponent == null) { int size = myButtonComponents.size(); if (size > 0) { int visibleCount = 0; for (Component component : myButtonComponents) { if (component.isVisible()) { width += component.getPreferredSize().width; visibleCount++; } } if (visibleCount > 0) { width += myBeforeButtonOffset.get(); width += (visibleCount - 1) * myButtonOffset.get(); } } } else if (leftOrder || myProgressDisabledButton == null) { width += myOffset.get() + myProgressComponent.getPreferredSize().width; } else { width = myProgressDisabledButton.getPreferredSize().width + myOffset.get() + myProgressComponent.getPreferredSize().width; } Insets insets = parent.getInsets(); return new Dimension(width, insets.top + baseSize.height + insets.bottom); }