< prev index next >
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java
Print this page
*** 206,215 ****
--- 206,217 ----
private boolean isRunsDirty;
private boolean calculatedBaseline;
private int baseline;
+ private TextUIDrawing textUIDrawing;
+
// UI creation
/**
* Create a UI.
* @param c a component
*** 413,422 ****
--- 415,425 ----
// if the keys are missing.
if (tabInsets == null) tabInsets = new Insets(0,4,1,4);
if (selectedTabPadInsets == null) selectedTabPadInsets = new Insets(2,2,2,1);
if (tabAreaInsets == null) tabAreaInsets = new Insets(3,2,0,2);
if (contentBorderInsets == null) contentBorderInsets = new Insets(2,2,3,3);
+ textUIDrawing = SwingUtilities2.getTextUIDrawing(textUIDrawing);
}
/**
* Uninstall the defaults.
*/
*** 428,437 ****
--- 431,444 ----
focus = null;
tabInsets = null;
selectedTabPadInsets = null;
tabAreaInsets = null;
contentBorderInsets = null;
+ if (textUIDrawing != SwingUtilities2.DEFAULT_UI_TEXT_DRAWING
+ && textUIDrawing instanceof UIResource) {
+ textUIDrawing = SwingUtilities2.DEFAULT_UI_TEXT_DRAWING;
+ }
}
/**
* Install the listeners.
*/
*** 940,952 ****
if (scrollableTabLayoutEnabled() && tabScroller.croppedEdge.isParamsSet() &&
tabScroller.croppedEdge.getTabIndex() == tabIndex && isHorizontalTabPlacement()) {
int availTextWidth = tabScroller.croppedEdge.getCropline() -
(textRect.x - tabRect.x) - tabScroller.croppedEdge.getCroppedSideWidth();
! clippedTitle = SwingUtilities2.clipStringIfNecessary(null, metrics, title, availTextWidth);
} else if (!scrollableTabLayoutEnabled() && isHorizontalTabPlacement()) {
! clippedTitle = SwingUtilities2.clipStringIfNecessary(null, metrics, title, textRect.width);
}
paintText(g, tabPlacement, font, metrics,
tabIndex, clippedTitle, textRect, isSelected);
--- 947,959 ----
if (scrollableTabLayoutEnabled() && tabScroller.croppedEdge.isParamsSet() &&
tabScroller.croppedEdge.getTabIndex() == tabIndex && isHorizontalTabPlacement()) {
int availTextWidth = tabScroller.croppedEdge.getCropline() -
(textRect.x - tabRect.x) - tabScroller.croppedEdge.getCroppedSideWidth();
! clippedTitle = textUIDrawing.getClippedString(null, metrics, title, availTextWidth);
} else if (!scrollableTabLayoutEnabled() && isHorizontalTabPlacement()) {
! clippedTitle = textUIDrawing.getClippedString(null, metrics, title, textRect.width);
}
paintText(g, tabPlacement, font, metrics,
tabIndex, clippedTitle, textRect, isSelected);
*** 1176,1196 ****
if (selectedFG != null) {
fg = selectedFG;
}
}
g.setColor(fg);
! SwingUtilities2.drawStringUnderlineCharAt(tabPane, g,
title, mnemIndex,
textRect.x, textRect.y + metrics.getAscent());
} else { // tab disabled
g.setColor(tabPane.getBackgroundAt(tabIndex).brighter());
! SwingUtilities2.drawStringUnderlineCharAt(tabPane, g,
title, mnemIndex,
textRect.x, textRect.y + metrics.getAscent());
g.setColor(tabPane.getBackgroundAt(tabIndex).darker());
! SwingUtilities2.drawStringUnderlineCharAt(tabPane, g,
title, mnemIndex,
textRect.x - 1, textRect.y + metrics.getAscent() - 1);
}
}
--- 1183,1203 ----
if (selectedFG != null) {
fg = selectedFG;
}
}
g.setColor(fg);
! textUIDrawing.drawStringUnderlineCharAt(tabPane, g,
title, mnemIndex,
textRect.x, textRect.y + metrics.getAscent());
} else { // tab disabled
g.setColor(tabPane.getBackgroundAt(tabIndex).brighter());
! textUIDrawing.drawStringUnderlineCharAt(tabPane, g,
title, mnemIndex,
textRect.x, textRect.y + metrics.getAscent());
g.setColor(tabPane.getBackgroundAt(tabIndex).darker());
! textUIDrawing.drawStringUnderlineCharAt(tabPane, g,
title, mnemIndex,
textRect.x - 1, textRect.y + metrics.getAscent() - 1);
}
}
*** 2024,2034 ****
// html
width += (int) v.getPreferredSpan(View.X_AXIS);
} else {
// plain text
String title = tabPane.getTitleAt(tabIndex);
! width += SwingUtilities2.stringWidth(tabPane, metrics, title);
}
}
return width;
}
--- 2031,2041 ----
// html
width += (int) v.getPreferredSpan(View.X_AXIS);
} else {
// plain text
String title = tabPane.getTitleAt(tabIndex);
! width += textUIDrawing.getStringWidth(tabPane, metrics, title);
}
}
return width;
}
< prev index next >