Dimension () { Dimension preferredSize = super.getPreferredSize(); int referencesSize = myReferencePainter.isLeftAligned() ? 0 : myReferencePainter.getSize().width; return new Dimension(preferredSize.width + referencesSize, getPreferredHeight()); }