Dimension () { Dimension size = addIconSize(super.getPreferredSize()); if (myValues != null) { String oldText = getText(); Icon oldIcon = getIcon(); for (int i = 0, limit = getPreferredSizeMaxValues(); i < myValues.length && i < limit; i++) { T v = myValues[i]; setText(getTextFor(v)); setIcon(getIconFor(v)); Dimension vSize = addIconSize(super.getPreferredSize()); size.width = Math.max(size.width, vSize.width); size.height = Math.max(size.height, vSize.height); } setText(oldText); setIcon(oldIcon); } return size; }