简体   繁体   English

构造JFrame时Java Web Start挂起

[英]Java Web Start hangs when constructing a JFrame

I need help when starting my program with Java Web Start. 使用Java Web Start启动程序时需要帮助。

I start my program from the homepage the program just hangs with a javaw-process in the process handler. 我从主页启动程序,该程序只是在进程处理程序中与javaw-process一起挂起。 When I dump the threads, using jvisualvm, I see that it hung in the "AWT-EventQueue-0" thread (when constructing my JFrame): 当我使用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)

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: 更新 :这是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>

What could be wrong?! 有什么问题吗? (It is the first place I touch the GUI and I'm on Windows XP.) (这是我触摸GUI的第一位,并且我在Windows XP上。)

Also, I noticed that I have another AWT thread (??!?!) also hanging at different places: 另外,我注意到我还有另一个AWT线程(??!?!)也挂在不同的地方:

From run 1 I got it to hang here: 从运行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)

And from run 2: 从运行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)

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

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). 看来只有在使用Intel HD Graphics(我的系统是Core i3 clarkdale)时才会发生。

Possible solutions are (tested!): 可能的解决方案(已测试!):

  • Using windows default drivers (~vga drivers) 使用Windows默认驱动程序(〜vga驱动程序)
  • New graphic card 新显卡

Certainly seems like some kind of problem with the graphics drivers and java. 当然,图形驱动程序和Java似乎存在某种问题。

See if this link to Java 2D system settings helps. 查看此指向Java 2D系统设置的链接是否有帮助。

Have you tried constructing the GUI in the main thread? 您是否尝试过在主线程中构造GUI? The event handling thread if for - handling events :-) 事件处理线程是否为-处理事件:-)

Try this code: 试试这个代码:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM