title: Creating a Drop Down Menu Bar in Java GUI
body: <p>I'm practicing creating a GUI program in Java using swing and awt imports. Most everything in my main class is working, except for getting a drop-down menu with a tab named file at the top of the GUI. I have two snippets of code, one in the JPanel class and the other in the public main() class. I ultimately want to get a file menu with save and save as options at the top. Don't need to invoke anything or add listeners, just to make them visible on the program itself. I'm using JMenuBar menuBar along with JMenu fileMenu to create it. What am I doing wrong? Snippets below:</p>
  
  <pre><code>JMenuBar menuBar = new JMenuBar();
  JMenuItem saveItem, saveAllItem;
  JMenuItem menuItem = new JMenuItem("Save");
  </code></pre>
  
  <hr>
  
  <pre><code>    setJMenuBar(menuBar);
      JMenu fileMenu = new JMenu("File");
      saveItem = fileMenu.add("Save");
      saveAllItem = fileMenu.add("Save All");
      panel.add(menuItem);
  
      setVisible(true);
  </code></pre>