This fixes the rendering of the JTabbedPane wrt my layoutCompoundLabel()
patch from yesterday.
2006-08-17 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/plaf/basic/BasicTabbedPaneUI.java
(layoutLabel): Reset the text and icon rectangles.
/Roman
Index: javax/swing/plaf/basic/BasicTabbedPaneUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java,v
retrieving revision 1.53
diff -u -1 -2 -r1.53 BasicTabbedPaneUI.java
--- javax/swing/plaf/basic/BasicTabbedPaneUI.java 16 Aug 2006 23:40:46 -0000 1.53
+++ javax/swing/plaf/basic/BasicTabbedPaneUI.java 18 Aug 2006 11:13:06 -0000
@@ -2445,25 +2445,24 @@
boolean isSelected = tabIndex == tabPane.getSelectedIndex();
// Paint background if necessary.
if (tabsOpaque || tabPane.isOpaque())
{
paintTabBackground(g, tabPlacement, tabIndex, rect.x, rect.y,
rect.width, rect.height, isSelected);
}
// Paint border.
paintTabBorder(g, tabPlacement, tabIndex, rect.x, rect.y, rect.width,
rect.height, isSelected);
-
// Layout label.
FontMetrics fm = getFontMetrics();
Icon icon = getIconForTab(tabIndex);
String title = tabPane.getTitleAt(tabIndex);
layoutLabel(tabPlacement, fm, tabIndex, title, icon, rect, iconRect,
textRect, isSelected);
// Paint the text.
paintText(g, tabPlacement, tabPane.getFont(), fm, tabIndex, title,
textRect, isSelected);
// Paint icon if necessary.
paintIcon(g, tabPlacement, tabIndex, icon, iconRect, isSelected);
@@ -2483,24 +2482,34 @@
* @param title The string painted.
* @param icon The icon painted.
* @param tabRect The tab bounds.
* @param iconRect The calculated icon bounds.
* @param textRect The calculated text bounds.
* @param isSelected Whether this tab is selected.
*/
protected void layoutLabel(int tabPlacement, FontMetrics metrics,
int tabIndex, String title, Icon icon,
Rectangle tabRect, Rectangle iconRect,
Rectangle textRect, boolean isSelected)
{
+ // Reset the icon and text rectangles, as the result is not specified
+ // when the locations are not (0,0).
+ textRect.x = 0;
+ textRect.y = 0;
+ textRect.width = 0;
+ textRect.height = 0;
+ iconRect.x = 0;
+ iconRect.y = 0;
+ iconRect.width = 0;
+ iconRect.height = 0;
SwingUtilities.layoutCompoundLabel(metrics, title, icon,
SwingConstants.CENTER,
SwingConstants.CENTER,
SwingConstants.CENTER,
SwingConstants.RIGHT, tabRect,
iconRect, textRect, textIconGap);
int shiftX = getTabLabelShiftX(tabPlacement, tabIndex, isSelected);
int shiftY = getTabLabelShiftY(tabPlacement, tabIndex, isSelected);
iconRect.x += shiftX;
iconRect.y += shiftY;