2011-04-04 55 views
0

當我按下執行查詢的按鈕時出現此錯誤。我不知道它是什麼。你們能幫助我嗎?JDialog中的異常

Exception occurred during event dispatching: 
java.lang.NullPointerException 
     at admin.add_special_features.enterActionPerformed(add_special_features.java:692) 
     at admin.add_special_features.access$3400(add_special_features.java:24) 
     at admin.add_special_features$35.actionPerformed(add_special_features.java:387) 
     at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995) 
     at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318) 
     at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) 
     at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) 
     at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) 
     at com.jtattoo.plaf.BaseButtonListener.mouseReleased(Unknown Source) 
     at java.awt.Component.processMouseEvent(Component.java:6263) 
     at javax.swing.JComponent.processMouseEvent(JComponent.java:3267) 
     at java.awt.Component.processEvent(Component.java:6028) 
     at java.awt.Container.processEvent(Container.java:2041) 
     at java.awt.Component.dispatchEventImpl(Component.java:4630) 
     at java.awt.Container.dispatchEventImpl(Container.java:2099) 
     at java.awt.Component.dispatchEvent(Component.java:4460) 
     at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574) 
     at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238) 
     at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168) 
     at java.awt.Container.dispatchEventImpl(Container.java:2085) 
     at java.awt.Window.dispatchEventImpl(Window.java:2475) 
     at java.awt.Component.dispatchEvent(Component.java:4460) 
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) 
     at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) 
     at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) 
     at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:178) 
     at java.awt.Dialog$1.run(Dialog.java:1045) 
     at java.awt.Dialog$3.run(Dialog.java:1097) 
     at java.security.AccessController.doPrivileged(Native Method) 
     at java.awt.Dialog.show(Dialog.java:1095) 
     at java.awt.Component.show(Component.java:1563) 
     at java.awt.Component.setVisible(Component.java:1515) 
     at java.awt.Window.setVisible(Window.java:841) 
     at java.awt.Dialog.setVisible(Dialog.java:985) 
     at admin.add_product.jButton2ActionPerformed(add_product.java:975) 
     at admin.add_product.access$3100(add_product.java:35) 
     at admin.add_product$33.actionPerformed(add_product.java:638) 
     at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995) 
     at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318) 
     at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) 
     at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) 
     at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) 
     at com.jtattoo.plaf.BaseButtonListener.mouseReleased(Unknown Source) 
     at java.awt.Component.processMouseEvent(Component.java:6263) 
     at javax.swing.JComponent.processMouseEvent(JComponent.java:3267) 
     at java.awt.Component.processEvent(Component.java:6028) 
     at java.awt.Container.processEvent(Container.java:2041) 
     at java.awt.Component.dispatchEventImpl(Component.java:4630) 
     at java.awt.Container.dispatchEventImpl(Container.java:2099) 
     at java.awt.Component.dispatchEvent(Component.java:4460) 
     at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574) 
     at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238) 
     at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168) 
     at java.awt.Container.dispatchEventImpl(Container.java:2085) 
     at java.awt.Window.dispatchEventImpl(Window.java:2475) 
     at java.awt.Component.dispatchEvent(Component.java:4460) 
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) 
     at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) 
     at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) 
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) 
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) 
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) 
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) 

回答

4

這意味着你正試圖解引用空引用。您應該檢查add_special_features.java的第692行,並查看可能爲空的所有引用。例如:

String x = null; 
System.out.println(x.length()); // Bang! 

這裏,我們通過調用它的length()方法試圖取消引用x ......但作爲xnull,它拋出一個NullPointerException