--- old/src/windows/classes/sun/awt/windows/WToolkit.java 2014-04-17 17:08:45.916607100 +0400 +++ new/src/windows/classes/sun/awt/windows/WToolkit.java 2014-04-17 17:08:45.279526200 +0400 @@ -72,6 +72,11 @@ 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. @@ -929,21 +934,31 @@ * Windows doesn't always send WM_SETTINGCHANGE when it should. */ private void windowsSettingChange() { - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - updateProperties(); + // 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(); + if (props != null) { + Object xpstyleOld = getDesktopProperty(XPSTYLE_THEME_ACTIVE); + Object xpstyleNew = props.get(XPSTYLE_THEME_ACTIVE); + if (xpstyleOld != null && !xpstyleOld.equals(xpstyleNew)) { + setDesktopProperty(XPSTYLE_THEME_ACTIVE, xpstyleNew); } - }); + + EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + 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(); for (String propName : props.keySet()) { Object val = props.get(propName); if (log.isLoggable(PlatformLogger.Level.FINER)) { @@ -953,6 +968,14 @@ } } + private synchronized void updateProperties() { + updateProperties(getWProps()); + } + + private synchronized Map getWProps() { + return wprops != null ? wprops.getProperties() : null; + } + @Override public synchronized void addPropertyChangeListener(String name, PropertyChangeListener pcl) { if (name == null) {