Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

displaying problem

 
Savanna Ray
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.

Savanna
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Savanna Ray
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic