Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4331508
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:07:09+00:00 2026-05-21T10:07:09+00:00

I am making this small and simple game with Java, and when I start

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T10:07:10+00:00Added an answer on May 21, 2026 at 10:07 am

    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.

    //Where the GUI is created:
    JMenuBar menuBar;
    JMenu menu;
    JMenuItem menuItem;
    
    //Create the menu bar.
    menuBar = new JMenuBar();
    
    //Build the first menu.
    menu = new JMenu("File");
    menu.setMnemonic(KeyEvent.VK_F);
    menu.getAccessibleContext().setAccessibleDescription(
            "File menu");
    menuBar.add(menu);
    
    //JMenuItems show the menu items
    menuItem = new JMenuItem("New",
                             new ImageIcon("images/new.gif"));
    menuItem.setMnemonic(KeyEvent.VK_N);
    menu.add(menuItem);
    
    // add a separator
    menu.addSeparator();
    
    menuItem = new JMenuItem("Pause", new ImageIcon("images/pause.gif"));
    menuItem.setMnemonic(KeyEvent.VK_P);
    menu.add(menuItem);
    
    menuItem = new JMenuItem("Exit", new ImageIcon("images/exit.gif"));
    menuItem.setMnemonic(KeyEvent.VK_E);
    menu.add(menuItem);
    
    // add menu bar to frame
    frame.setJMenuBar(theJMenuBar);
    

    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:

    menuItem.addActionListener(new ActionListener() { // ...});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm thinking about making a networked game. I'm a little new to this, and
I've been trying to make a little simple game just to test my logics,
I'm making a simple 2D game for the iPhone. It's based on CrashLanding. so
I'm making a simple 2 player game in XNA and started looking into saving
I am making a small game as sort of a test project, nothing major.
This is making me kind of crazy: I did a mysqldump of a partitioned
Im making a small python script to upload files on the net. The script
Summary: Can I program a thick client game in C without reinventing wheels ,
I have a game engine that uses OpenGL for display. I coded a small
I'd like to rank a collection of landscape images by making a game whereby

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.