This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes problems with displaying.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "problems with displaying.." Watch "problems with displaying.." New topic
Author

problems with displaying..

Savanna Ray
Greenhorn

Joined: Nov 20, 2004
Posts: 9
Hello,

I'm trying to display a 3 x 3 grid made up of an array of 9 individual cell objects. I created two classes, one for each cell, and one for the whole board. So far, I can only display the board 'border'. When I try to invoke the method to draw each cell from the Board class, i get a null pointer exception error within the black dos window for some reason?? Would anyone care to take a look and give a little feedback? I would really appreciate it.

Here's the code:



Thanks
from BC
Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
Hello Savanna,

Your problem lies in the Board constructor. You have instanciated TWO arrays of cells. One here:



and a second here:



The first one is an instance variable and the second one a local variable.

The one you are using in the drawBoard method is the instance variable which contains null values hence the null pointer exception you get.

Change your Board class to that:



Tell me if that helped,

Julien.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problems with displaying..