2010-11-08 59 views
0

使用Java Web Start啓動程序時需要幫助。構建JFrame時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> 

出了什麼問題? (這是第一個地方,我接觸到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) 

回答

0

如果有人發現另一種解決辦法我直接接受它!我沒有與當前的解決方案蔑視......


似乎採用了英特爾高清顯卡(我的系統是酷睿i3的Clarkdale)時,它纔會發生。

可能的解決方案(經測試!):

  • 使用Windows默認的驅動程序(〜VGA驅動程序)
  • 新顯卡
0

嘗試設置f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

+0

在我有機會這樣做之前,它會掛起。 – dacwe 2010-11-08 14:42:31

+0

您是否能夠在本地運行jar而沒有問題?如果是,那麼可能發佈jnlp文件。 – deorst 2010-11-08 16:06:44

+0

添加了jnlp! (感謝提示) – dacwe 2010-11-09 08:53:23

-1

您是否嘗試在主線程中構建GUI?該事件處理線程如果 - 處理事件:-)

+0

嗯,我敢肯定,你甚至不應該在另一個線程中構建gui,但我會嘗試! :) – dacwe 2010-11-08 14:43:35

+0

不,沒有工作。 – dacwe 2010-11-08 15:06:05

-1

試試這個代碼:

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

試過了,沒有工作。它只是掛在「javawsApplicationMain」中。 – dacwe 2010-11-08 15:54:22