< prev index next >
src/java.desktop/share/classes/javax/swing/plaf/ComponentUI.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -28,14 +28,14 @@
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.accessibility.Accessible;
import java.awt.Component;
-import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
-import java.awt.Insets;
+import javax.swing.UIManager;
+import sun.swing.SwingUtilities2;
/**
* The base class for all UI delegate objects in the Swing pluggable
* look and feel architecture. The UI delegate object for a Swing
@@ -50,10 +50,13 @@
* @see javax.swing.JComponent
* @see javax.swing.UIManager
*
*/
public abstract class ComponentUI {
+
+ private TextUIDrawing textUIDrawing;
+
/**
* Sole constructor. (For invocation by subclass constructors,
* typically implicit.)
*/
public ComponentUI() {
@@ -83,10 +86,18 @@
* @see #uninstallUI
* @see javax.swing.JComponent#setUI
* @see javax.swing.JComponent#updateUI
*/
public void installUI(JComponent c) {
+
+ if (textUIDrawing == null || textUIDrawing instanceof UIResource) {
+ textUIDrawing = (TextUIDrawing) UIManager.get("uiDrawing.text");
+ }
+
+ if (textUIDrawing == null) {
+ textUIDrawing = SwingUtilities2.DEFAULT_UI_TEXT_DRAWING;
+ }
}
/**
* Reverses configuration which was done on the specified component during
* <code>installUI</code>. This method is invoked when this
@@ -111,10 +122,13 @@
*
* @see #installUI
* @see javax.swing.JComponent#updateUI
*/
public void uninstallUI(JComponent c) {
+ if (textUIDrawing instanceof UIResource) {
+ textUIDrawing = null;
+ }
}
/**
* Paints the specified component appropriately for the look and feel.
* This method is invoked from the <code>ComponentUI.update</code> method when
@@ -363,6 +377,18 @@
* @see #getAccessibleChildrenCount
*/
public Accessible getAccessibleChild(JComponent c, int i) {
return SwingUtilities.getAccessibleChild(c, i);
}
+
+ /**
+ * Returns the {@code TextUIDrawing} instance responsible for text drawing
+ * and measuring.
+ *
+ * @return {@code TextUIDrawing} instance
+ *
+ * @since 9
+ */
+ public TextUIDrawing getTextUIDrawing() {
+ return textUIDrawing;
+ }
}
< prev index next >