代码之家  ›  专栏  ›  技术社区  ›  dacwe

JavaWeb启动在构建JFrm时挂起

  •  0
  • dacwe  · 技术社区  · 14 年前

    在用Java Web start启动程序时,我需要帮助。

    我从主页启动我的程序,程序在进程处理程序中挂起一个javaw进程。当我使用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>
    

    可能有什么问题?! (这是我触摸图形用户界面的第一个地方,我在Windows XP上。)

    另外,我注意到我有另一个awt线程(??!?!)也悬挂在不同的地方:

    从第一次跑步开始,我就把它挂在这里:

    "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)
    
    5 回复  |  直到 14 年前
        1
  •  0
  •   deorst    14 年前

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

        2
  •  0
  •   dacwe    14 年前

    如果有人找到另一个解决方案,我直接接受它! 我不轻视当前的解决方案…


    似乎只有在使用英特尔高清图形系统(我的系统是核心i3 Clarkdale)时才会发生这种情况。

    可能的解决方案已测试!:

    • 使用Windows默认驱动程序(~vga驱动程序)
    • 新图形卡
        3
  •  0
  •   obscuredlogic    14 年前

    看起来像是图形驱动程序和Java的一些问题。

    看看是否 this link to Java 2D system settings 帮助。

        4
  •  -1
  •   kresho    14 年前

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

        5
  •  -1
  •   Faisal Feroz    14 年前

    试试这个代码:

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