aplet 上的 pData 为空

发布于 2024-11-04 05:08:08 字数 1286 浏览 0 评论 0原文

我有一个 Java 小程序,我尝试从中调用 getContext().showDocument(aUrl) 来导航到另一个网页。尽管浏览器正确导航到新页面,但我在 Java 插件控制台中不断收到此令人讨厌的异常:

Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException: null pData
    at sun.awt.windows.WComponentPeer.getLocationOnScreen(Native Method)
    at java.awt.Component.getLocationOnScreen_NoTreeLock(Unknown Source)
    at java.awt.Component.getLocationOnScreen(Unknown Source)
    at java.awt.LightweightDispatcher$3.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

当调用 showDocument() 方法时,控件位于 AWT 的事件调度内部线程,我认为在事件调度线程完成处理当前事件和小程序之前加载新页面时会引发异常已经是了。

该异常似乎是无害的,尽管我注意到当它被抛出时,小程序的 destroy() 方法不再被调用,这在理论上可能会导致问题。

谷歌搜索这个问题出现了很多类似问题的报告,但没有明确的解决方案。有人知道我该如何克服这个问题吗?这是一个已知的错误吗?有快速修复之类的吗?

此致, 担。

I have a Java applet from which I try to call getContext().showDocument(aUrl) to navigate to another web page. Although the browser correctly navigates to the new page, I keep getting this nasty exception in the Java Plugin Console:

Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException: null pData
    at sun.awt.windows.WComponentPeer.getLocationOnScreen(Native Method)
    at java.awt.Component.getLocationOnScreen_NoTreeLock(Unknown Source)
    at java.awt.Component.getLocationOnScreen(Unknown Source)
    at java.awt.LightweightDispatcher$3.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

When calling the showDocument() method, the control is inside AWT's event dispatch thread and I reckon the exception is thrown when the new page is loaded before the event dispatch thread has finished processing the current event and the applet is already .

The exception seems to be harmless although I have noticed that when it gets thrown, the applet's destroy() method is not called anymore which theoretically can lead to problems.

A google search on this issue comes up with a lot of reports on similar problems but there is no clear solution. Has anybody got any idea how can I overcome this problem? Is this a known bug? Is there a quick fix or something?

Best regards,
Dan.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撩人痒 2024-11-11 05:08:08

SwingUtilities ' invokeLater 可能会帮助你。
这个想法是在处理所有事件后推迟对显示文档的调用。只需使用您的代码创建一个 Runnable 实例并调用它即可。

SwingUtilities' invokeLater might help you.
The idea is to deffer the call to show document after all the events were processed. Just create a Runnable instance with your code and invoke it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文