aspose file tools*
The moose likes Beginning Java and the fly likes Reseting an applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Reseting an applet" Watch "Reseting an applet" New topic
Author

Reseting an applet

Martin vanPutten
Ranch Hand

Joined: Mar 26, 2006
Posts: 124
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.


Live And Let Learn.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

Well, using a KeyListener. Implement a KeyListener, add it to the Applet, and in the implementation, do your resetting or whatever.


[Jess in Action][AskingGoodQuestions]
Martin vanPutten
Ranch Hand

Joined: Mar 26, 2006
Posts: 124
whats the command for reset?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
There is no API call to put the applet back to its pristine state. You'll have to implement that.


Ping & DNS - updated with new look and Ping home screen widget
Martin vanPutten
Ranch Hand

Joined: Mar 26, 2006
Posts: 124
I don't understand how to implement it. Can somebody give me a short example?
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

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 ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reseting an applet
 
Similar Threads
database connection from applets
Help with Jbuttons JText Lotto
requestFocus question (not too urgent but I am curious)
html:button underline
how to reset the field after validation using annotations(Struts 2)