src/share/classes/com/sun/java/swing/plaf/windows/XPStyle.java

Print this page

        

@@ -42,18 +42,20 @@
 
 import java.awt.*;
 import java.awt.image.*;
 import java.security.AccessController;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import javax.swing.*;
 import javax.swing.border.*;
 import javax.swing.plaf.*;
 import javax.swing.text.JTextComponent;
 
 import sun.awt.image.SunWritableRaster;
 import sun.awt.windows.ThemeReader;
+import sun.awt.windows.WToolkit;
 import sun.security.action.GetPropertyAction;
 import sun.swing.CachedPainter;
 
 import static com.sun.java.swing.plaf.windows.TMSchema.*;
 

@@ -70,10 +72,12 @@
     // Singleton instance of SkinPainter
     private static SkinPainter skinPainter = new SkinPainter();
 
     private static Boolean themeActive = null;
 
+    private static final AtomicBoolean xpstyleEnabled = WToolkit.getWToolkit().getXPStyleEnabled();
+
     private HashMap<String, Border> borderMap;
     private HashMap<String, Color>  colorMap;
 
     private boolean flatMenus;
 

@@ -94,17 +98,16 @@
      *
      * @return the singleton instance of this class or null if XP styles
      * are not active or if this is not Windows XP
      */
     static synchronized XPStyle getXP() {
-        if (themeActive == null) {
-            Toolkit toolkit = Toolkit.getDefaultToolkit();
-            themeActive =
-                (Boolean)toolkit.getDesktopProperty("win.xpstyle.themeActive");
-            if (themeActive == null) {
-                themeActive = Boolean.FALSE;
+        if (themeActive != null && themeActive.booleanValue() != xpstyleEnabled.get()) {
+            // JDK-8039383: theme changed, schedule updateAllUIs()
+            DesktopProperty.scheduleUpdateUI();
             }
+        if (themeActive == null) {
+            themeActive = Boolean.valueOf(xpstyleEnabled.get());
             if (themeActive.booleanValue()) {
                 GetPropertyAction propertyAction =
                     new GetPropertyAction("swing.noxp");
                 if (AccessController.doPrivileged(propertyAction) == null &&
                     ThemeReader.isThemed() &&