File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes displaying problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "displaying problem" Watch "displaying problem" New topic

displaying problem

Savanna Ray

Joined: Nov 20, 2004
Posts: 9

I'm trying to display a 3X3 grid for a tictactoe game, here's the code so far:

This program actually compiles, but for some reason it won't display anything when I run the program? Any help would be appreciated. Thanks.

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

There's nothing here that will ever call "display()". You could override the paint(Graphics) method of Applet and call it there:

That will get you started.

The next problem you're likely to face is that the dimensions of the board aren't based on those of the applet, so probably you'll only see part of the board. Instead of the sizes being fixed in Board, the Board should get the sizes from the applet, either as constructor arguments, or by being made into a Component itself, added to the applet, which would have its own coordinates.

[Jess in Action][AskingGoodQuestions]
Savanna Ray

Joined: Nov 20, 2004
Posts: 9
Thanks for replying, Ernest!

I tried adding the paint method, tictac.display(g), but nothing appeared on the display. The "dos" window shows a 'NullPointerException' at Board.display line 63. Maybe there's a problem in passing the values to the draw method?
I agree. Here's the link:
subject: displaying problem
It's not a secret anymore!