--- old/src/windows/classes/sun/awt/windows/WToolkit.java 2014-06-06 12:20:39.101634400 +0400 +++ new/src/windows/classes/sun/awt/windows/WToolkit.java 2014-06-06 12:20:38.551564600 +0400 @@ -72,6 +72,9 @@ private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WToolkit"); + // Desktop property which specifies whether XP visual styles are in effect + public static final String XPSTYLE_THEME_ACTIVE = "win.xpstyle.themeActive"; + static GraphicsConfiguration config; // System clipboard. @@ -894,7 +897,7 @@ private synchronized void lazilyInitWProps() { if (wprops == null) { wprops = new WDesktopProperties(this); - updateProperties(); + updateProperties(wprops.getProperties()); } } @@ -929,21 +932,27 @@ * Windows doesn't always send WM_SETTINGCHANGE when it should. */ private void windowsSettingChange() { + // JDK-8039383: Have to update the value of XPSTYLE_THEME_ACTIVE property + // as soon as possible to prevent NPE and other errors because theme data + // has become unavailable. + final Map props = getWProps(); + updateXPStyleEnabled(props.get(XPSTYLE_THEME_ACTIVE)); + EventQueue.invokeLater(new Runnable() { @Override public void run() { - updateProperties(); + updateProperties(props); } }); } - private synchronized void updateProperties() { - if (null == wprops) { - // wprops has not been initialized, so we have nothing to update + private synchronized void updateProperties(final Map props) { + if (null == props) { return; } - Map props = wprops.getProperties(); + updateXPStyleEnabled(props.get(XPSTYLE_THEME_ACTIVE)); + for (String propName : props.keySet()) { Object val = props.get(propName); if (log.isLoggable(PlatformLogger.Level.FINER)) { @@ -953,6 +962,14 @@ } } + private synchronized Map getWProps() { + return (wprops != null) ? wprops.getProperties() : null; + } + + private void updateXPStyleEnabled(final Object dskProp) { + ThemeReader.xpStyleEnabled = Boolean.TRUE.equals(dskProp); + } + @Override public synchronized void addPropertyChangeListener(String name, PropertyChangeListener pcl) { if (name == null) {