File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in thread "main" java.lang.NullPointerException

 
Andrew Sepulveda
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the user interface class



the main class




I am not sure why I am getting this...



I am running on eclipse and it does not show in the code itself that it is an error, only in the console.
Anybody realize why this is happening?
 
Ralph Cook
Ranch Hand
Posts: 479
  • 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the great things about Java is that the error messages usually give you a good idea of what's going on; just read them carefully.

In your case it says "NullPointerException", and "failure.java:22", meaning line 22 in that class.

line 22 contains "item.addItemListener..."; you should be wondering if item has been instantiated.

And you can look back and see that, although you declared item to be a JComboBox, you never instantiated a JComboBox to put in it.

rc
 
Andrew Sepulveda
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you. the program now works functionally.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic