-
CSR
-
Resolution: Withdrawn
-
P3
-
None
-
minimal
-
-
Java API
Summary
This change adds two methods to javax.swing.LookAndFeel
,
uninstallColors
and uninstallColorsAndFont
, which correspond
to the existing installColors
and installColorsAndFont
methods.
Problem
installColors
and installColorsAndFont
can be used to install
properties that may implement UIResource
, and which should be
uninstalled at uninstall time. Many of the current callers of the methods
fail to uninstall them.
Solution
The solution is to add uninstallColors
and uninstallColorsAndFont
which uninstall any UIResource
properties installed by
installColors
and installColorsAndFont
, to make it easy to callers of those methods to correctly handle uninstallation.
Specification
diff --git a/src/java.desktop/share/classes/javax/swing/LookAndFeel.java b/src/java.desktop/share/classes/javax/swing/LookAndFeel.java
index 830fadb1c0c..b2a907da307 100644
--- a/src/java.desktop/share/classes/javax/swing/LookAndFeel.java
+++ b/src/java.desktop/share/classes/javax/swing/LookAndFeel.java
@@ -187,6 +187,25 @@ public abstract class LookAndFeel
}
+ /**
+ * Convenience method for uninstalling a component's foreground
+ * and background color properties. If the properties are
+ * {@code UIResource}s, they are set to {@code null}.
+ *
+ * @param c component to uninstall the properties from
+ * @see #uninstallColorsAndFont
+ * @throws NullPointerException if {@code c} is {@code null}
+ */
+ public static void uninstallColors(JComponent c) {
+ if (c.getForeground() instanceof UIResource) {
+ c.setForeground(null);
+ }
+ if (c.getBackground() instanceof UIResource) {
+ c.setBackground(null);
+ }
+ }
+
+
/**
* Convenience method for setting a component's foreground,
* background and font properties with values from the
@@ -217,6 +236,22 @@ public abstract class LookAndFeel
}
+ /**
+ * Convenience method for uninstalling a component's foreground,
+ * background, and font properties. If the properties are
+ * {@code UIResource}s, they are set to {@code null}.
+ *
+ * @param c component to uninstall the properties from
+ * @throws NullPointerException if {@code c} is {@code null}
+ */
+ public static void uninstallColorsAndFont(JComponent c) {
+ if (c.getFont() instanceof UIResource) {
+ c.setFont(null);
+ }
+ uninstallColors(c);
+ }
+
+
/**
* Convenience method for setting a component's border property with
* a value from the defaults. The border is only set if the border is
- csr of
-
JDK-8277817 java/awt/dnd/BadSerializationTest/BadSerializationTest.java failed: ClassNotFoundException: com.apple.laf.AquaImageFactory$SystemColorProxy
-
- Open
-