It's not a secret anymore!
The moose likes Applets and the fly likes Restart game button? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Restart game button?" Watch "Restart game button?" New topic

Restart game button?

Harry Rollins

Joined: May 03, 2012
Posts: 1
Hi guys,

I am a beginner Java programmer and I have made a very simple applet with the wonderful help of some great YouTube tutorials and I was wondering if you guys knew of anyway of making a button that restarted the game without having to exit and reload the game manually. Here is my main class:

Any suggestions or code alterations would be so gratefully received also any other comments on the code would be nice as well.


Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
create a method, separate to init() or start(), named reset()? and put your current start-up code there.
ensure you set any variables to their starting state (except for games won/lost etc).

call reset() when the applet first opens, then for a new game call reset() again,
and the screen should appear exactly as when the applet first opened.
Darryl Burke

Joined: May 03, 2008
Posts: 5115

Please BeForthrightWhenCrossPostingToOtherSites

luck, db
There are no new questions, but there may be new answers.
I agree. Here's the link:
subject: Restart game button?
jQuery in Action, 3rd edition