• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reseting an applet

 
Martin vanPutten
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I reset the applet by having a keypress such as "R" for reset? I made a game and when its over, I'd like the player to push "r" to simply reset it if they wish.
 
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
Well, using a KeyListener. Implement a KeyListener, add it to the Applet, and in the implementation, do your resetting or whatever.
 
Martin vanPutten
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
whats the command for reset?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no API call to put the applet back to its pristine state. You'll have to implement that.
 
Martin vanPutten
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand how to implement it. Can somebody give me a short example?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically, write a method that reassigns all the variables back to what they were when the Applet was first initialized.

(I say "basically" because if the variables reference objects that change state, then those objects might need to be "reset" as well. And so on.)
[ May 18, 2006: Message edited by: marc weber ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic