Dimension (final boolean mainTextOnly) { synchronized (myFragments) { // Calculate width float width = myIpad.left; if (myIcon != null) { width += myIcon.getIconWidth() + myIconTextGap; } final Insets borderInsets = myBorder != null ? myBorder.getBorderInsets(this) : JBInsets.emptyInsets(); width += borderInsets.left; Font font = getBaseFont(); width += computeTextWidth(font, mainTextOnly); width += myIpad.right + borderInsets.right; // Take into account that the component itself can have a border final Insets insets = getInsets(); if (insets != null) { width += insets.left + insets.right; } int height = computePreferredHeight(); return new Dimension((int)Math.ceil(width), height); } }