0

I have been playing around with trying to get a menu screen for my game. I have only been able to figure out how to paint a new Screen on top of an existing one; meaning that the actual game is still running behind the title screen. I don't need actual code but just a description of how I would go about this.

x3zinja12
  • 21
  • 1
  • 1
  • 5
  • 1
    I'm not sure what you mean by your terms -- "menu screen":do you mean another window, independent of the "game screen"? Then you mention "title screen". 'Screen' seems to be used mostly to refer to the hardware screen, so please describe what you want/mean more fully. – arcy Jan 12 '12 at 03:09
  • I mean the area that is displayed inside of the window. I draw the objects to the JFrame window and the menu of the game gets drawn on top of that. I need the game to run only the menu and not run the actual game, which is simply not drawn but still running in the background. – x3zinja12 Jan 14 '12 at 19:10

1 Answers1

2

One way to display a menu would by by using a JDialog outside of your main application window. Take a look at the How to Make Dialogs tutorial for more information.

Another possibility would be to use JInternalFrame for your game and menu so they can be wrapped in a larger application frame. These are explained nicely in How to Use Internal Frames

Jason Braucht
  • 2,358
  • 19
  • 31
  • I meant a title screen that takes up the entire window until the user presses the spacebar which will start the game. – x3zinja12 Jan 15 '12 at 05:39
  • Not sure if I'm corrcctly understanding what you are trying to do, but it sounds like maybe you could use [CardLayout](http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/CardLayout.html) to swap between panels. This could be used to give the appearance of changing "screens". There is a [CardLayout tutorial](http://docs.oracle.com/javase/tutorial/uiswing/layout/card.html) which explains more about how to do this. – Jason Braucht Jan 15 '12 at 05:57