构建 JFrame 时 Java Web Start 挂起

发布于 2024-10-01 08:02:38 字数 5690 浏览 3 评论 0原文

使用 Java Web Start 启动程序时我需要帮助。

我从主页启动我的程序,程序只是挂在进程处理程序中的 javaw-process 中。当我使用 jvisualvm 转储线程时,我看到它挂在“AWT-EventQueue-0”线程中(构建 JFrame 时):

"AWT-EventQueue-0" prio=6 tid=0x02da7c00 nid=0x1414 runnable [0x0367f000]
    java.lang.Thread.State: RUNNABLE
        at sun.awt.windows.WToolkit.getScreenInsets(Native Method)
        at sun.awt.windows.WToolkit.getScreenInsets(Unknown Source)
        at java.awt.Window.init(Unknown Source)
        at java.awt.Window.<init>(Unknown Source)
        at java.awt.Frame.<init>(Unknown Source)
        at javax.swing.JFrame.<init>(Unknown Source)
        at se.testing.Application$2.run(Application.java:170)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

这是主要内容:

public static void main(String... args) {

    ....

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            JFrame f = new JFrame("Test");
            ...
        }
    });
}

更新:这里jnlp 文件:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="6.0+" 
      codebase="http://localhost/archive/Application-1.0.0/"
      href="application.jnlp">
  <information>
    <title>Application</title>
    <vendor>Testing</vendor>
    <homepage href="http://localhost/" />
    <description></description>
    <offline-allowed/>
  </information>
  <security>
    <all-permissions/>
  </security>
  <update check="timeout" policy="always" />
  <resources>
    <j2se version="1.6+"/>
    <jar href="Application-1.0.0.jar" main="true"/>
    <jar href="Framework-1.0.0.jar"/>
    <jar href="WebServices-1.0.0.jar"/>
    <jar href="axis-1.4.jar"/>
    <jar href="axis-jaxrpc-1.4.jar"/>
    <jar href="log4j-1.2.14.jar"/>
    <jar href="spring-2.5.5.jar"/>
    <jar href="commons-logging-1.1.1.jar"/>
    <jar href="commons-net-2.0.jar"/>
    <jar href="nanoxml-2.2.3.jar"/>
    <jar href="jtds-1.2.2.jar"/>
    <jar href="commons-discovery-0.4.jar"/>
    <jar href="wsdl4j-1.6.2.jar"/>
  </resources>
  <application-desc main-class="se.testing.Application">
  </application-desc>
</jnlp>

可能出了什么问题?! (这是我第一次接触 GUI,而且我使用的是 Windows XP。)

此外,我注意到我还有另一个 AWT 线程 (??!?!) 也挂在不同的位置:

从运行 1 开始,我让它挂起这里:

"AWT-EventQueue-1" prio=6 tid=0x03448800 nid=0x152c runnable [0x036cf000]
    java.lang.Thread.State: RUNNABLE
        at sun.awt.windows.WComponentPeer.nativeHandleEvent(Native Method)
        at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
        at sun.awt.windows.WWindowPeer.handleEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
        at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
        at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.SequencedEvent.dispatch(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.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

从运行 2 开始:

"AWT-EventQueue-1" prio=6 tid=0x03448800 nid=0x1638 runnable [0x036cf000]
    java.lang.Thread.State: RUNNABLE
        at sun.awt.windows.WToolkit.isWindowTranslucencySupported(Native Method)
        at com.sun.awt.AWTUtilities.isWindowTranslucencySupported(Unknown Source)
        at com.sun.awt.AWTUtilities.isTranslucencySupported(Unknown Source)
        at javax.swing.RepaintManager.updateWindows(Unknown Source)
        at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
        at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(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.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

I need help when starting my program with Java Web Start.

I start my program from the homepage the program just hangs with a javaw-process in the process handler. When I dump the threads, using jvisualvm, I see that it hung in the "AWT-EventQueue-0" thread (when constructing my JFrame):

"AWT-EventQueue-0" prio=6 tid=0x02da7c00 nid=0x1414 runnable [0x0367f000]
    java.lang.Thread.State: RUNNABLE
        at sun.awt.windows.WToolkit.getScreenInsets(Native Method)
        at sun.awt.windows.WToolkit.getScreenInsets(Unknown Source)
        at java.awt.Window.init(Unknown Source)
        at java.awt.Window.<init>(Unknown Source)
        at java.awt.Frame.<init>(Unknown Source)
        at javax.swing.JFrame.<init>(Unknown Source)
        at se.testing.Application$2.run(Application.java:170)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

Here is what the main looks like:

public static void main(String... args) {

    ....

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            JFrame f = new JFrame("Test");
            ...
        }
    });
}

Update: And here is the jnlp file:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="6.0+" 
      codebase="http://localhost/archive/Application-1.0.0/"
      href="application.jnlp">
  <information>
    <title>Application</title>
    <vendor>Testing</vendor>
    <homepage href="http://localhost/" />
    <description></description>
    <offline-allowed/>
  </information>
  <security>
    <all-permissions/>
  </security>
  <update check="timeout" policy="always" />
  <resources>
    <j2se version="1.6+"/>
    <jar href="Application-1.0.0.jar" main="true"/>
    <jar href="Framework-1.0.0.jar"/>
    <jar href="WebServices-1.0.0.jar"/>
    <jar href="axis-1.4.jar"/>
    <jar href="axis-jaxrpc-1.4.jar"/>
    <jar href="log4j-1.2.14.jar"/>
    <jar href="spring-2.5.5.jar"/>
    <jar href="commons-logging-1.1.1.jar"/>
    <jar href="commons-net-2.0.jar"/>
    <jar href="nanoxml-2.2.3.jar"/>
    <jar href="jtds-1.2.2.jar"/>
    <jar href="commons-discovery-0.4.jar"/>
    <jar href="wsdl4j-1.6.2.jar"/>
  </resources>
  <application-desc main-class="se.testing.Application">
  </application-desc>
</jnlp>

What could be wrong?!
(It is the first place I touch the GUI and I'm on Windows XP.)

Also, I noticed that I have another AWT thread (??!?!) also hanging at different places:

From run 1 I got it to hang here:

"AWT-EventQueue-1" prio=6 tid=0x03448800 nid=0x152c runnable [0x036cf000]
    java.lang.Thread.State: RUNNABLE
        at sun.awt.windows.WComponentPeer.nativeHandleEvent(Native Method)
        at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
        at sun.awt.windows.WWindowPeer.handleEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
        at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
        at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.SequencedEvent.dispatch(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.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

And from run 2:

"AWT-EventQueue-1" prio=6 tid=0x03448800 nid=0x1638 runnable [0x036cf000]
    java.lang.Thread.State: RUNNABLE
        at sun.awt.windows.WToolkit.isWindowTranslucencySupported(Native Method)
        at com.sun.awt.AWTUtilities.isWindowTranslucencySupported(Unknown Source)
        at com.sun.awt.AWTUtilities.isTranslucencySupported(Unknown Source)
        at javax.swing.RepaintManager.updateWindows(Unknown Source)
        at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
        at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(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.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

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

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

发布评论

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

评论(5

素年丶 2024-10-08 08:02:38

尝试设置f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Try to set f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

苏辞 2024-10-08 08:02:38

如果有人找到其他解决方案,我会直接接受!我并不鄙视当前的解决方案...


似乎只有在使用 Intel HD Graphics 时才会发生这种情况(我的系统是 Core i3clarkdale)。

可能的解决方案是(经过测试!):

  • 使用 Windows 默认驱动程序(~vga 驱动程序)
  • 新显卡

If someone finds another solution I accept it directly! I'm not contempt with the current solution...


It seems that it only happens when using Intel HD Graphics (my system is Core i3 clarkdale).

Possible solutions are (tested!):

  • Using windows default drivers (~vga drivers)
  • New graphic card
无法回应 2024-10-08 08:02:38

当然看起来像是图形驱动程序和 java 的某种问题。

查看此链接是否指向 Java 2D 系统设置有帮助。

Certainly seems like some kind of problem with the graphics drivers and java.

See if this link to Java 2D system settings helps.

梦里的微风 2024-10-08 08:02:38

您是否尝试过在主线程中构建 GUI?事件处理线程 if for - 处理事件:-)

Have you tried constructing the GUI in the main thread? The event handling thread if for - handling events :-)

離人涙 2024-10-08 08:02:38

试试这个代码:

public static void main(String... args) {
    JFrame f = new JFrame("Test");
    f.setVisible( true );
}

Try this code:

public static void main(String... args) {
    JFrame f = new JFrame("Test");
    f.setVisible( true );
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文