I am having issue with jmenu popup in netbeans. It only sometimes works. Sometimes I don't get a java popup at all. Sometimes my File and Edit options are completely missing. This is what my code looks like.

import javax.swing.*;

public class menu {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        JFrame f = new JFrame();
        f.setVisible(true);
        f.setSize(400,400);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setLocationRelativeTo(null);

        JMenuBar mb = new JMenuBar();

        JMenu file = new JMenu ("File");
        mb.add(file);
        JMenu edit = new JMenu("Edit");
        mb.add(edit);

        f.setJMenuBar(mb);
    }

}

I don't see anything wrong with the code, tried running it using terminal as well, works fine. Could be something with Netbins itself

Netbeans is picky about the order. When I moved this to the bottom of main it works as expected :).

f.setVisible(true);

Glad it works then ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.