int () { if (myTextAlign == SwingConstants.LEFT || myTextAlign == SwingConstants.LEADING) { return 0; } int componentWidth = getSize().width; int excessiveWidth = componentWidth - computePreferredSize(false).width; if (excessiveWidth <= 0) { return 0; } if (myTextAlign == SwingConstants.CENTER) { return excessiveWidth / 2; } if (myTextAlign == SwingConstants.RIGHT || myTextAlign == SwingConstants.TRAILING) { return excessiveWidth; } return 0; }