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

  • SEARCH
  • Home
  • 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 6872727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:57:57+00:00 2026-05-27T03:57:57+00:00

my JMenuBar is not showing AT ALL. This is just a barebones GUI. I

  • 0

my JMenuBar is not showing AT ALL. This is just a barebones GUI. I have sat here for quite a while now, and I cannot see the problem, soo, as they say, four eyes are better than two.

Thanks.

import javax.swing.*;
import java.awt.*;

public class MainGui{
    private DrawPanel drawPanel;
    private JFrame mainFrame;
    private JPanel drawPanel;
    private JMenuBar menuBar;
    private JMenu fileMenu, imgMenu, helpMenu;
    private JMenuItem fileNew, fileOpen, fileSave, fileExit;
    private JMenuItem imgBtn1;
    private JMenuItem hlpAbout;

    public MainGui(DrawPanel drawPanel){
    mainFrame = new JFrame("JDraw v1");
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setLayout(new BorderLayout());

    this.drawPanel = drawPanel;

    menuBar = new JMenuBar();
    fileMenu = new JMenu("File");
    imgMenu = new JMenu("Image");
    helpMenu = new JMenu("Help");

    fileNew = new JMenuItem("New File");
    fileOpen = new JMenuItem("Open File");
    fileSave = new JMenuItem("Save File");
    fileExit = new JMenuItem("Exit");
    imgBtn1 = new JMenuItem("Useless Button");
    hlpAbout = new JMenuItem("About this program");

    mainFrame.add(menuBar, BorderLayout.PAGE_START);
    menuBar.add(fileMenu);
    menuBar.add(imgMenu);
    menuBar.add(hlpMenu);

    fileMenu.add(fileNew);
    fileMenu.add(fileOpen);
    fileMenu.add(fileSave);
    fileMenu.add(fileExit);
    imgMenu.add(imgBtn1);
    helpMenu.add(hlpAbout);

    mainFrame.add(drawPanel, BorderLayout.CENTER);

    mainFrame.pack();
    mainFrame.setSize(640,480);
    mainFrame.setResizable(false);
    mainFrame.setVisible(true);
    }
}
  • 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-27T03:57:58+00:00Added an answer on May 27, 2026 at 3:57 am

    You want to do:

    mainFrame.setJMenuBar(menuBar);
    

    not:

    mainFrame.add(menuBar, BorderLayout.PAGE_START);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java GUI project containing a JMenuBar and I just added a
The JMenuBar does not start showing JMenuItem s as selected or displaying the JMenu
I have a program that is not showing any errors in Eclipse, but whenever
If I have defined JMenu and JMenuBar like this: private JMenuBar jMenuBar; private JMenu
I have some JScrollPanes on my hex editor and they're not showing up. Any
My main class displays a JMenuBar. This JMenuBar is managed from calculator.ui.MenuBar. public JMenuBar
I have a frame containing a JMenuBar. If the users clicks the Logout MenuItem,
INTRO: I created a java application using JFrame. I have a JMenuBar at the
I am trying to get my JMenuBar to display in the GUI, however it
Any idea why the menu bar menuBar is not showing? everything looks fine to

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.