"java.lang.InternalError:HTHEME为空"在任意JRE上(Windows) [英] "java.lang.InternalError: HTHEME is null" on arbitrary JREs (Windows)

查看:100
本文介绍了"java.lang.InternalError:HTHEME为空"在任意JRE上(Windows)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行Java应用程序时(通过right-click Desktop > Personalize)更改Windows 7上的Windows主题时,我们遇到异常.搜索网络确实产生了一些结果,但是它们主要是关于Java错误报告的,这些报告声称已经解决了很久.这是经过修剪和部分混淆的堆栈跟踪:

We are getting an exception when changing the Windows Theme on Windows 7 (via right-click Desktop > Personalize) while our Java app is running. Searching the web did produce some results, but they are mostly about java bug reports that claim to have been resolved ages ago. This is the trimmed and partially obfuscated stack trace:

java.lang.InternalError: HTHEME is null
    at sun.awt.windows.ThemeReader.paintBackground(Native Method)
    at sun.awt.windows.ThemeReader.paintBackground(Unknown Source)
    at com.sun.java.swing.plaf.windows.XPStyle$SkinPainter.paintToImage(Unknown Source)
    at sun.swing.CachedPainter.paint0(Unknown Source)
    at sun.swing.CachedPainter.paint(Unknown Source)
    at com.sun.java.swing.plaf.windows.XPStyle$Skin.paintSkinRaw(Unknown Source)
    at com.sun.java.swing.plaf.windows.AnimationController.paintSkin(Unknown Source)
    at com.sun.java.swing.plaf.windows.XPStyle$Skin.paintSkin(Unknown Source)
    at com.sun.java.swing.plaf.windows.XPStyle$Skin.paintSkin(Unknown Source)
    at com.sun.java.swing.plaf.windows.WindowsScrollBarUI.paintThumb(Unknown Source)
    at javax.swing.plaf.basic.BasicScrollBarUI.paint(Unknown Source)
    at javax.swing.plaf.ComponentUI.update(Unknown Source)
    at javax.swing.JComponent.paintComponent(Unknown Source)
    at javax.swing.JComponent.paint(Unknown Source)
    at javax.swing.JComponent.paintChildren(Unknown Source)
    at javax.swing.JComponent.paint(Unknown Source)
    at javax.swing.JComponent.paintChildren(Unknown Source)
    at javax.swing.JComponent.paint(Unknown Source)
    at javax.swing.JComponent.paintChildren(Unknown Source)
    at javax.swing.JComponent.paint(Unknown Source)
    at javax.swing.JComponent.paintChildren(Unknown Source)
    at javax.swing.JComponent.paint(Unknown Source)
    at javax.swing.JComponent.paintChildren(Unknown Source)
    at javax.swing.JComponent.paint(Unknown Source)
    at javax.swing.JComponent.paintChildren(Unknown Source)
    at javax.swing.JComponent.paint(Unknown Source)
    at javax.swing.JComponent.paintChildren(Unknown Source)
    at javax.swing.JComponent.paint(Unknown Source)
    at javax.swing.JLayeredPane.paint(Unknown Source)
    at javax.swing.JComponent.paintChildren(Unknown Source)
    at javax.swing.JComponent.paintToOffscreen(Unknown Source)
    at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
    at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
    at javax.swing.RepaintManager.paint(Unknown Source)
    at javax.swing.JComponent.paint(Unknown Source)
    at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
    at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
    at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
    at java.awt.Container.paint(Unknown Source)
    at java.awt.Window.paint(Unknown Source)
    at javax.swing.RepaintManager$4.run(Unknown Source)
    at javax.swing.RepaintManager$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
    at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
    at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
    at javax.swing.RepaintManager.access$1200(Unknown Source)
    at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$500(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.WaitDispatchSupport$2.run(Unknown Source)
    at java.awt.WaitDispatchSupport$4.run(Unknown Source)
    at java.awt.WaitDispatchSupport$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.WaitDispatchSupport.enter(Unknown Source)
    at java.awt.Dialog.show(Unknown Source)
    at java.awt.Component.show(Unknown Source)
    at java.awt.Component.setVisible(Unknown Source)
    at java.awt.Window.setVisible(Unknown Source)
    at java.awt.Dialog.setVisible(Unknown Source)
    at com.example.App$130$1.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$500(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.WaitDispatchSupport$2.run(Unknown Source)
    at java.awt.WaitDispatchSupport$4.run(Unknown Source)
    at java.awt.WaitDispatchSupport$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.WaitDispatchSupport.enter(Unknown Source)
    ... goes on and on

它似乎与LAF有关.应用不支持在启动后更改LAF.它确实会调用

It seems to be related to LAF. The app does not support changing LAF after startup. It does call

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

但是,在启动时.这是在运行 1.8.0_74 64bit 任意JRE版本的Windows 7 Enterprise x64计算机上发生的. 是一个Java错误报告的示例,该报告看起来非常相似,并且应该解决了.

at startup, however. This happens on a Windows 7 Enterprise x64 machine, running 1.8.0_74 64bit an arbitrary JRE version. This is an example of a Java bug report which appears to be quite similar and is supposedly resolved.

有人可以阐明原因可能是什么,以及如何解决(除了明显的请勿在Windows上设置系统外观")之外?

Can anyone shed some light on what the cause may be and how it may be worked around (besides the obvious "do not set system look and feel on Windows")?

P.S .:链接的错误报告中的一条评论声称:

P.S.: A comment in the linked bug report claims:

一个很好的重现此问题的应用程序是SwingSet3( https://java.net/projects/Swingset3).

将外观"更改为Windows,然后在左侧的组件列表中单击JInternalFrame.再创建几个内部框架.尝试切换Windows主题:Windows 7 Basic ??? Windows经典版.

Change Look-and-Feel to Windows, and click JInternalFrame in the list of components on the left. Create several more internal frames. Try switching Windows themes: Windows 7 Basic ??? Windows Classic.

但是我们没有运气,它只发生了一次,而SwingSet3却显示了JTable.

but we had no luck doing that it only happened a single time for us, while SwingSet3 was showing a JTable.

这确实发生在Windows主题更改期间-手动完成或用户通过远程桌面登录到运行Java应用程序的计算机时.为了确保界面的响应速度更快,可能会禁用Aero并可能会自动切换到基于Windows Classic的主题.我已经相应地编辑了问题.

this indeed happens during Windows Theme changing - either when done manually or when the user logs on to the machine running the Java app through Remote Desktop. To ensure a more responsive interface, Aero may be disabled and a switch to Windows Classic based theme may be made automatically. I've edited the question accordingly.

推荐答案

解决此问题的唯一方法是忽略此特定异常,而不是将其扔到用户的脸上,这正是我们所做的.由于它是在绘画过程中发生的,因此不会造成重大伤害,并且该应用程序可以正常运行(至少在测试过程中).这可能是没人在乎实际修复它的原因(除了Swing随着时间的流逝慢慢消失).

The only way around this is to ignore this specific exception instead of throwing it into your user's face, which is exactly what we did. Since it happens during painting, there's no major harm done and the app survives it just fine (during testing at least). This is probably the reason no one cares about actually fixing it (besides Swing dying slowly over time).

如果出现HTHEME is null异常,并且堆栈跟踪中提到了表头渲染器,请阅读此答案(如果您如此)正在使用包装默认渲染器的自定义渲染器.那是一个适当的解决方案.

If you get HTHEME is null exception and the stack trace mentions a table header renderer, read this answer, if you are using a custom renderer that wraps the default one. That one has a proper solution.

这篇关于"java.lang.InternalError:HTHEME为空"在任意JRE上(Windows)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆