< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java

Print this page

        

@@ -206,10 +206,12 @@
     private boolean isRunsDirty;
 
     private boolean calculatedBaseline;
     private int baseline;
 
+    private TextUIDrawing textUIDrawing;
+
 // UI creation
 
     /**
      * Create a UI.
      * @param c a component

@@ -413,10 +415,11 @@
         // 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,10 +431,14 @@
         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,13 +947,13 @@
 
             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);
+                clippedTitle = textUIDrawing.getClippedString(null, metrics, title, availTextWidth);
             } else if (!scrollableTabLayoutEnabled() && isHorizontalTabPlacement()) {
-                clippedTitle = SwingUtilities2.clipStringIfNecessary(null, metrics, title, textRect.width);
+                clippedTitle = textUIDrawing.getClippedString(null, metrics, title, textRect.width);
             }
 
             paintText(g, tabPlacement, font, metrics,
                     tabIndex, clippedTitle, textRect, isSelected);
 

@@ -1176,21 +1183,21 @@
                     if (selectedFG != null) {
                         fg = selectedFG;
                     }
                 }
                 g.setColor(fg);
-                SwingUtilities2.drawStringUnderlineCharAt(tabPane, g,
+                textUIDrawing.drawStringUnderlineCharAt(tabPane, g,
                              title, mnemIndex,
                              textRect.x, textRect.y + metrics.getAscent());
 
             } else { // tab disabled
                 g.setColor(tabPane.getBackgroundAt(tabIndex).brighter());
-                SwingUtilities2.drawStringUnderlineCharAt(tabPane, g,
+                textUIDrawing.drawStringUnderlineCharAt(tabPane, g,
                              title, mnemIndex,
                              textRect.x, textRect.y + metrics.getAscent());
                 g.setColor(tabPane.getBackgroundAt(tabIndex).darker());
-                SwingUtilities2.drawStringUnderlineCharAt(tabPane, g,
+                textUIDrawing.drawStringUnderlineCharAt(tabPane, g,
                              title, mnemIndex,
                              textRect.x - 1, textRect.y + metrics.getAscent() - 1);
 
             }
         }

@@ -2024,11 +2031,11 @@
                 // html
                 width += (int) v.getPreferredSpan(View.X_AXIS);
             } else {
                 // plain text
                 String title = tabPane.getTitleAt(tabIndex);
-                width += SwingUtilities2.stringWidth(tabPane, metrics, title);
+                width += textUIDrawing.getStringWidth(tabPane, metrics, title);
             }
         }
         return width;
     }
 
< prev index next >