• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error occured during event dispathching

 
bobby, morkos
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get an error occured during an event dispatching
java.lang.NullPointerException ...
Could anyone tell me why I get this error when a click a button, and how do I avoid this. Thanks.
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NullPointerException is one of the most common Runtime exceptions people get.
this usally means u r trying to use a method or to access a refrence variable that is pointing to null rather than an object.
usually this means that u just forgot to create an object and u r trying to run methods on it, like this:
Button x;
x.setForeground(Color.red);
here x is just pointing to null so u cant activate methods on it.
u need to make a NEW object like this:
Button x=new Button("OK");
x.setForeground(Color.red);
i belive u have the same kind of mistake in your program.
just check if u forgot to make new objects for you references.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!