0

I programmed the game Hangman, which displays all its components onto one panel.

That panel is then displayed onto the JFrame but now I want to have a startup screen with two different buttons, "normal mode" and "timed mode". I also want to have a win and losing screen both of which have a label stating that "you won/lost."

They also have 3 different buttons, "play again","go to main menu", and "exit". Can someone explain how I would go about doing this?

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720

1 Answers1

1
  • Separating each screen in individual components (most likely based on a JPanel).
  • Set the layout manager for your "main" container to CardLayout.
  • Add each screen to the "main" container, by name as per the requirements of the CardLayout
  • Switch between the screens as required.

Personally, I would have some kind of model/controller which new how to manage this setup, so when the program starts, you tell the controller to show the "start up" screen. Then from there, the "start up" screen can tell the controller what it wants loaded next, etc

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366