Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException  RSS feed

 
Kenn Briones
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I call a method from another class and get this error after clicking the button Next


This is build2()


and this is the button


Why does this happen?
 
Tim Moores
Saloon Keeper
Posts: 3831
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The stack trace says the exception occurs in line 188 of class StudSubj; which line is that? And which object used in that line is null?
 
Les Morgan
Rancher
Posts: 767
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see build2 there, but I don't see any buttons. That ActionListener is not what you report it to be, so perhaps it may be your problem that this not your code? In any case, it is at Tim said, you are not showing any part of the code that is generating the problem.
 
Kenn Briones
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The build2() in the ButtonHandler is the line 188 in the class StudSubj. it is the one causing the problem.
 
Tim Moores
Saloon Keeper
Posts: 3831
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that you mean lines 21 and/or 41: what is "aD"? When is it set? Have you checked that it is not null before using it?
 
Kenn Briones
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The aD is set in the StudSubj class.


And this is the whole AllDetails class
 
Tim Moores
Saloon Keeper
Posts: 3831
80
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's where aD is declared, but not set. So, again: Have you checked that it is not null before using it?
 
Kenn Briones
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh. I get it. aD is null.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!