title: How do I integrate a menu into a layout (Java GUI)?
body: <p>I am trying to add a menu to this program, but I am having trouble with it.  I think the code for the menu itself is okay, but I cannot figure out how to actually insert it into my GUI.  In this project I have 4 classes.  One for some JRadioButtons, one to add a large text field, one for the menu, and then one final one to put it all together.  When I run the program without the menu class, this is the output.<a href="https://i.stack.imgur.com/N2MFi.png" rel="nofollow noreferrer">Output of program without menu class</a></p>
  
  <p>Here is some of the code as well.  </p>
  
  <pre><code>JRadioButton encrypt1 = new JRadioButton("Reverse Word" );
  JRadioButton encrypt2 = new JRadioButton("+1");
  ButtonGroup group1 = new ButtonGroup();
  
  JRadioButton decrypt1 = new JRadioButton("Reverse Word");
  JRadioButton decrypt2 = new JRadioButton("+1");
  ButtonGroup group2 = new ButtonGroup();
  
  public chooseEncryption(){
      setLayout(new GridLayout(3, 4));
  
      panel1 = new JPanel(); panel2 = new JPanel(); panel3 = new JPanel();
      panel4 = new JPanel(); panel5 = new JPanel(); panel6 = new JPanel();
      panel7 = new JPanel(); panel8 = new JPanel(); panel9 = new JPanel();
      panel10 = new JPanel(); panel11 = new JPanel(); panel12 = new JPanel();
  
      encryptionLabel = new JLabel("Encryption");
      decryptionLabel = new JLabel("Decryption");
      group1.add(encrypt1);
      group1.add(encrypt2);
      group2.add(decrypt1);
      group2.add(decrypt2);
  
      panel2.add(encryptionLabel);
      panel4.add(decryptionLabel);
      panel6.add(encrypt1);
      panel8.add(decrypt1);
      panel10.add(encrypt2);
      panel12.add(decrypt2);
  
      add(panel1); add(panel2); add(panel3); add(panel4); add(panel5);
      add(panel6); add(panel7); add(panel8); add(panel9); add(panel10);
      add(panel11); add(panel12);
  }
  </code></pre>
  
  <p>That's the radio button class, and then I integrate it using this putTogether class.</p>
  
  <pre><code>public putTogether(){ //Constructor of putTogether class
      setTitle("Encryption Program");
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setLayout(new BorderLayout());
  
      panel = new chooseEncryption(); //object of radio button class
      panel2 = new textField(); //object of text field class
  
  
      add(panel, BorderLayout.NORTH);
      add(panel2, BorderLayout.CENTER);
      pack();
      setVisible(true);
  }
  </code></pre>
  
  <p>And here is part of the menu class.</p>
  
  <pre><code>public class menu extends JFrame{
  
      public void buildMenuBar(){
          menuBar = new JMenuBar();
  
          buildFileMenu();
          buildEditMenu();
          buildHelpMenu();
  
          menuBar.add(fileMenu);
          menuBar.add(editMenu);
          menuBar.add(helpMenu);
  
          setJMenuBar(menuBar);
      }
  </code></pre>
  
  <p>How would I set up the menu so that it becomes part of the GUI.  I know it has something to do with creating a constructor for it, but I haven't been able to make any progress.  I appreciate the help on this!</p>