Question

I'm not sure why my JMenuBar isn't showing up.The other 2 panels that I add show up just fine.I'm not sure if it has something to do with borderLayout being picky or what. I'm sure(hope) it is something small. I'm just learning how to create GUIs so that is entirely possible. Thanks for any help in advance.

    public homeGUI()
{
    super("Pixfile Photo Manager");
    setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
    setLayout(new BorderLayout(2,5));
    setDefaultCloseOperation(3);
    initComponants();
    initHeaderPanel();
    buildFileListPanel();
    createMenuBar();

    add(headerPanel, "Center");
    add(fileListPanel, "West");

    this.setJMenuBar(menuBar);
    setLocationRelativeTo(null);
    setVisible(true);
}

public void createMenuBar(){
    menuBar = new JMenuBar();
    fileMenu = new JMenu();
    manageMenu = new JMenu();
    aboutMenu = new JMenu();

    menuBar.add(fileMenu);
    menuBar.add(manageMenu);
    menuBar.add(aboutMenu);
}
Was it helpful?

Solution

Without text, the JMenus will not appear in the menu bar:

fileMenu = new JMenu("File");
manageMenu = new JMenu("Manage");
aboutMenu = new JMenu("About");

Aside: Avoid using magic numbers for window close operations (3 = EXIT_ON_CLOSE):

setDefaultCloseOperation(EXIT_ON_CLOSE)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top