• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Calling the repaint() method

 
Ranch Hand
Posts: 206
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am developing a game called Tic Tac Toe. I first made a standalone application and then converted it into a JApplet.
In my game i have a button called as "New Game". Whenever a user presses this button the game is started all over again. The problem is, i have written some logic for it, but it is not working.

The problem is, i dont know wat to put in the paint method. In my case all the logic is implemented in init() and actionPerformed() method. So my paint method is empty. And when i call repaint(), it is having no effect.

Which logic should come in the paint method?

Below is the code which i have written till now.

 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> i dont know wat to put in the paint method.

you don't need to put anything there.

the game changes/paints itself via
pressedButton.setText(letter);

so, for new game, iterate the buttons clearing the x/o's via setText("")
and you would need to reset player turn and any other variable you use in the game
 
chander shivdasani
Ranch Hand
Posts: 206
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To the above code, i added the following code in the actionPerformed method



Even after doing this,the "new game" button does not produce any effect
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
did you add a listener to the button?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic