1

I have a Swing application that is running on RDP sandbox. The RDP connection has option 'Visual styles' which is responsible for displaying or ignoring Windows themes. First time I connect with the option checked and run my Swing application. Then I disconnect and reconnect again with unchecked 'Visual styles' option. And exception immediately occurs:

    java.lang.AssertionError: part MENU.MP_POPUPCHECK is not defined
    at com.sun.java.swing.plaf.windows.XPStyle.getSkin(XPStyle.java:452)
    at com.sun.java.swing.plaf.windows.WindowsIconFactory$VistaMenuItemCheckIconFactory.getIconWidth(WindowsIconFactory.java:688)
    at com.sun.java.swing.plaf.windows.WindowsLookAndFeel$1.createValue(WindowsLookAndFeel.java:1698)
    at com.sun.java.swing.plaf.windows.WindowsLookAndFeel$XPValue.recursiveCreateValue(WindowsLookAndFeel.java:2382)
    at com.sun.java.swing.plaf.windows.WindowsLookAndFeel$XPValue.getXPValue(WindowsLookAndFeel.java:2370)
    at com.sun.java.swing.plaf.windows.WindowsLookAndFeel$XPValue.createValue(WindowsLookAndFeel.java:2357)
    at javax.swing.UIDefaults.getFromHashtable(UIDefaults.java:231)
    at javax.swing.UIDefaults.get(UIDefaults.java:161)
    at javax.swing.MultiUIDefaults.get(MultiUIDefaults.java:64)
    at javax.swing.UIManager.get(UIManager.java:955)
    at sun.swing.MenuItemLayoutHelper.getMinTextOffset(MenuItemLayoutHelper.java:215)
    at sun.swing.MenuItemLayoutHelper.reset(MenuItemLayoutHelper.java:138)
    at sun.swing.MenuItemLayoutHelper.<init>(MenuItemLayoutHelper.java:107)
    at javax.swing.plaf.basic.BasicMenuItemUI.paintMenuItem(BasicMenuItemUI.java:507)

As I figured out com.sun.java.swing.plaf.windows.XPStyle#getXP should return null if Windows themes are disabled but it doesn't.

The ThemeReader class does initialize UIDefaults successfully with native method sun.awt.windows.ThemeReader#initThemes but when it tries to get the theme it returns 0 because themes are disabled now.

So I think sun.awt.windows.ThemeReader#initThemes works incorrect in this case or may be there is any way to reset it hard?

4

0 回答 0