EVALUATION
This is a regression from the fix for the bug #6464003,
after that fix we pay attention to the left and right text bearings.
In the provided test case the right bearing of the text "Probably" is 1,
because the letter "y" is sligtly overlaps the text bounds,
it leads to the fact that SwingUtilities.layoutCompoundLabelImpl()
assumes that text width is more than the view width and clip the text.
The suggested fix:
We shouldn't clip the text and add ellipsis at the end
if we didn't do it before, so I suggest calculate if we need to clip the text
without bearings first and take bearing into account only after that
SwingUtilities.layoutCompoundLabelImpl()
lines 1008 - 1034
// moved it from the label 1:
// clip the text here, before working with bearings
if (textR.width > availTextWidth) {
text = SwingUtilities2.clipString(c, fm, text,
availTextWidth);
textR.width = SwingUtilities2.stringWidth(c, fm, text);
}
// Take into account the left and right side bearings.
// This gives more space than it is actually needed,
// but there are two reasons:
// 1. If we set the width to the actual bounds,
// all callers would have to account for the bearings
// themselves. NOTE: all pref size calculations don't do it.
// 2. You can do a drawString at the returned location
// and the text won't be clipped.
lsb = SwingUtilities2.getLeftSideBearing(c, fm, text);
if (lsb < 0) {
textR.width -= lsb;
}
rsb = SwingUtilities2.getRightSideBearing(c, fm, text);
if (rsb > 0) {
textR.width += rsb;
}
// label 1:
|