2014-06-19 48 views
-4

寬多拉ejecuto我馬卡報埃斯特錯誤 `異常時。 Java的:136) 在javax.swing.AbstractButton.fireActionPerformed(來源不明) 在javax.swing.AbstractButton中的$ Handler.actionPerformed(來源不明) 在javax.swing.DefaultButtonModel.fireActionPerformed(來源不明) 在javax.swing中.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt (未知源) at javax.swing.JComponent.processMouseEvent(未知源) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java .awt.Component.dispatchEventImpl(未知來源) 在java.awt.Container.dispatchEventImpl(未知來源) 在java.awt.Component.dispatchEvent(未知來源) 在java.awt.LightweightDispatcher.retargetMouseEvent(未知來源) java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.a wt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access $ 200(Unknown Source) java.awt.EventQueue $ 3.run(Unknown Source) at java.awt.EventQueue $ 3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain $ 1.doIntersectionPrivilege (Unknown Source) at java.security.ProtectionDomain $ 1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue $ 4.run(Unknown Source) at java.awt.EventQueue $ 4.run(Unknown Source) at java。 security.AccessController.doPriv ileged(本機方法) 在java.security.ProtectionDomain $ 1.doIntersectionPrivilege(來源不明) 在java.awt.EventQueue.dispatchEvent(來源不明) 在java.awt.EventDispatchThread.pumpOneEventForFilters(來源不明) 在java.awt中.EventDispatchThread.pumpEventsForFilter(未知來源) 在java.awt.EventDispatchThread.pumpEventsForHierarchy(未知來源) 在java.awt.EventDispatchThread.pumpEvents(未知來源) 在java.awt.EventDispatchThread.pumpEvents(未知源)」NullPointerException異常在線程 「AWT-EventQueue的-0」 顯示java.lang.NullPointerException 在ventana.VentanaPrincipal.actionPerformed(VentanaPrincipal使得從一個JDialog更改一個JFrame

+1

看行號.'VentanaPrincipal.java:136'。你能多解釋一下嗎? – Braj

+1

你能發佈與這個堆棧跟蹤相關的代碼嗎? –

回答

2

你必須確保你已經實例化了新的JDialogJFrame個,當你切換窗口:

JDialog newDialog = new JDialog(); 
JFrame newFrame = new JFrame(); 

如果你嘗試切換到任何newDialog或實例他們之前,你會得到你NullPointerException。此外,您應該閱讀The Use of Multiple JFrames, Good/Bad Practice?

相關問題