I am trying to create a sample program that has a menu and some options on it. The problem is When i run the program, the menu does not appear until the window is re-sized. I am not sure what the problem is and I would appreciate any help.
Here is the code that I am working with:
P.S. I already imported all of the libraries that I need.
public class TextEditor {
public static void main(String[] args) {
JFrame f = new JFrame();
f.setSize(700,500);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setResizable(true);
f.setVisible(true);
JMenuBar menuBar = new JMenuBar();
f.setJMenuBar(menuBar);
JMenu file = new JMenu("File");
menuBar.add(file);
JMenuItem open = new JMenuItem("Open File");
file.add(open);
}
}