title: How do I add my menubar class to my JFrame which is in my Main Class
body: <p>I am unsure on the code to connect my MenuDriver class to my JFrame which is in Main class. I understand that this could all be done in the main class, but I am being told to have a separate class for the menu.</p>
  
  <pre><code>Main-
  import java.awt.BorderLayout;
  import java.awt.Component;
  import java.awt.MenuBar;
  
  import javax.swing.JFrame;
  
  public class GraphicMain {
  
      public static void main(String[] args) {
          JFrame frame = new JFrame("Graphics Program");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setSize(400, 600);
  
          MenuDriver menu = new MenuDriver();
  
          frame.pack();
          frame.setVisible(true);
      }
  }
  </code></pre>
  
  <p>Menu Class-</p>
  
  <pre><code>import java.awt.*;
  
  import javax.swing.*;
  public class MenuDriver {
  
      public MenuDriver(){
          JMenuBar menubar = new JMenuBar();
  
          JMenu file = new JMenu("File");
          menubar.add(file);
  
          JMenuItem load = new JMenuItem("Load");
          file.add(load);
  
          JMenuItem save = new JMenuItem("Save");
          file.add(save);
  
          JMenuItem exit = new JMenuItem("Exit");
          file.add(exit);
  
          JMenu help = new JMenu("Help");
          menubar.add(help);
  
          JMenuItem info = new JMenuItem("Info");
          file.add(info);
          }
  }
  </code></pre>