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:
parent
4824dc2041
commit
3abc91d13d
@ -1138,7 +1138,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants {
|
|||||||
int tabIndex, Icon icon, Rectangle iconRect,
|
int tabIndex, Icon icon, Rectangle iconRect,
|
||||||
boolean isSelected ) {
|
boolean isSelected ) {
|
||||||
if (icon != null) {
|
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);
|
icon.paintIcon(tabPane, g, iconRect.x, iconRect.y);
|
||||||
|
g.setClip(oldClip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +326,11 @@ public class SynthGraphicsUtils {
|
|||||||
*/
|
*/
|
||||||
public void paintText(SynthContext ss, Graphics g, String text,
|
public void paintText(SynthContext ss, Graphics g, String text,
|
||||||
Rectangle bounds, int mnemonicIndex) {
|
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);
|
paintText(ss, g, text, bounds.x, bounds.y, mnemonicIndex);
|
||||||
|
g.setClip(oldClip);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -621,15 +621,17 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
|
|||||||
|
|
||||||
if (tabPane.getTabComponentAt(tabIndex) == null) {
|
if (tabPane.getTabComponentAt(tabIndex) == null) {
|
||||||
String title = tabPane.getTitleAt(tabIndex);
|
String title = tabPane.getTitleAt(tabIndex);
|
||||||
|
String clippedTitle = title;
|
||||||
Font font = ss.getStyle().getFont(ss);
|
Font font = ss.getStyle().getFont(ss);
|
||||||
FontMetrics metrics = SwingUtilities2.getFontMetrics(tabPane, g, font);
|
FontMetrics metrics = SwingUtilities2.getFontMetrics(tabPane, g, font);
|
||||||
Icon icon = getIconForTab(tabIndex);
|
Icon icon = getIconForTab(tabIndex);
|
||||||
|
|
||||||
layoutLabel(ss, tabPlacement, metrics, tabIndex, title, icon,
|
layoutLabel(ss, tabPlacement, metrics, tabIndex, title, icon,
|
||||||
tabRect, iconRect, textRect, isSelected);
|
tabRect, iconRect, textRect, isSelected);
|
||||||
|
clippedTitle = SwingUtilities2.clipStringIfNecessary(null, metrics,
|
||||||
|
title, textRect.width);
|
||||||
paintText(ss, g, tabPlacement, font, metrics,
|
paintText(ss, g, tabPlacement, font, metrics,
|
||||||
tabIndex, title, textRect, isSelected);
|
tabIndex, clippedTitle, textRect, isSelected);
|
||||||
|
|
||||||
paintIcon(g, tabPlacement, tabIndex, icon, iconRect, isSelected);
|
paintIcon(g, tabPlacement, tabIndex, icon, iconRect, isSelected);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 4310381
|
* @bug 4310381 8075918
|
||||||
* @summary Text in multi-row/col JTabbedPane tabs can be truncated/clipped
|
* @summary Text in multi-row/col JTabbedPane tabs can be truncated/clipped
|
||||||
* @author Charles Lee
|
* @author Charles Lee
|
||||||
@run applet/manual=yesno bug4310381.html
|
@run applet/manual=yesno bug4310381.html
|
||||||
|
Loading…
Reference in New Issue
Block a user