8075918: The regression-swing case failed as the long Tab titles are not clipped with dots at the end with NimbusLookAndFeel

Reviewed-by: serb, aniyogi
This commit is contained in:
Prasanta Sadhukhan 2017-06-21 10:30:25 +05:30
parent 4824dc2041
commit 3abc91d13d
4 changed files with 13 additions and 3 deletions

View File

@ -1138,7 +1138,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
int tabIndex, Icon icon, Rectangle iconRect,
boolean isSelected ) {
if (icon != null) {
// Clip the icon within iconRect bounds
Shape oldClip = g.getClip();
((Graphics2D)g).clip(iconRect);
icon.paintIcon(tabPane, g, iconRect.x, iconRect.y);
g.setClip(oldClip);
}
}

View File

@ -326,7 +326,11 @@ public class SynthGraphicsUtils {
*/
public void paintText(SynthContext ss, Graphics g, String text,
Rectangle bounds, int mnemonicIndex) {
// Clip the text within textRect bounds
Shape oldClip = g.getClip();
((Graphics2D)g).clip(bounds);
paintText(ss, g, text, bounds.x, bounds.y, mnemonicIndex);
g.setClip(oldClip);
}
/**

View File

@ -621,15 +621,17 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
if (tabPane.getTabComponentAt(tabIndex) == null) {
String title = tabPane.getTitleAt(tabIndex);
String clippedTitle = title;
Font font = ss.getStyle().getFont(ss);
FontMetrics metrics = SwingUtilities2.getFontMetrics(tabPane, g, font);
Icon icon = getIconForTab(tabIndex);
layoutLabel(ss, tabPlacement, metrics, tabIndex, title, icon,
tabRect, iconRect, textRect, isSelected);
clippedTitle = SwingUtilities2.clipStringIfNecessary(null, metrics,
title, textRect.width);
paintText(ss, g, tabPlacement, font, metrics,
tabIndex, title, textRect, isSelected);
tabIndex, clippedTitle, textRect, isSelected);
paintIcon(g, tabPlacement, tabIndex, icon, iconRect, isSelected);
}

View File

@ -27,7 +27,7 @@
/*
* @test
* @bug 4310381
* @bug 4310381 8075918
* @summary Text in multi-row/col JTabbedPane tabs can be truncated/clipped
* @author Charles Lee
@run applet/manual=yesno bug4310381.html