昨天刚考完试,没想到考的刚好是我考前做的一道题,也刚好那时还遗留了一个错误,结果我照着我做过的做完之后,就剩下那个报错了,搞了大概40分钟之后,还是没有做出来,最后,在我们班学委的帮助下,总算是解决了,希望能对大家有帮助,报错如下:
Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException: Cannot invoke “javax.swing.JComboBox.getSelectedItem()” because “this.bookType” is null
at View.ShowFrame.AddBook(ShowFrame.java:184)
at View.ShowFrame 2. a c t i o n P e r f o r m e d ( S h o w F r a m e . j a v a : 128 ) a t j a v a . d e s k t o p / j a v a x . s w i n g . A b s t r a c t B u t t o n . f i r e A c t i o n P e r f o r m e d ( A b s t r a c t B u t t o n . j a v a : 1967 ) a t j a v a . d e s k t o p / j a v a x . s w i n g . A b s t r a c t B u t t o n 2.actionPerformed(ShowFrame.java:128) at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967) at java.desktop/javax.swing.AbstractButton 2.actionPerformed(ShowFrame.java:128)atjava.desktop/javax.swing.AbstractButton.fireActionPerformed(A