0

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);
    }

}
2
Contributors
3
Replies
12
Views
2 Years
Discussion Span
Last Post by Slavi
0

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

0

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

f.setVisible(true);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.