• Post Reply Bookmark Topic Watch Topic
  • New Topic

EventQueue null pointer error  RSS feed

 
Gus Smith
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again, getting an annoying eventqueue error and hoping somebody can nudge me in the right direction.

The error:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at MinesweeperView$Controller.mouseClicked(MinesweeperView.java:75)

Here's the suspect code:

The error occurs on a mouse click of a button on my GUI, just after after the if check and before the model.step method is called the first time around. As far as I can tell I've initialised everything properly here:


Is it a problem with the method call itself, the initialising or I have just made a typo somewhere? I can post more code if necessary. Thanks.
 
Rob Spoor
Sheriff
Posts: 21133
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since e cannot be null*, either button is null or button[i] is null. How do you instantiate the array?

* unless you call the method yourself with null as its argument.
 
Gus Smith
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do it using the init method:

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!