I am making this small and simple game with Java, and when I start it up, it just starts the game without any menus or something. Now, I want to make it so that if I run the game, there comes a game menu, or starting menu, where you can select new game, and exit. But, how would I do this? I need some help with this.
Edit:
The game is in a 800×600 screen, and I want like, a menu that takes over the whole 800×600 screen, with just a “Start Game” and a “Exit” button.
The Swing tutorial on menus will be an excellent reference for you as you work through creating a menu.
Here is some sample code for creating a simple menu like you described, assuming your JFrame is called
frame.The important classes to know are JMenuBar, JMenu, and JMenuItem.
To handle clicks on those menu items, you need to add an ActionListener for each, using code such as: