title: How can I outsource the method of a menu to a separate class?
body: <p>Yesterday I started Coding a program in Java Swing. Before I coded only small console programs in java.</p>
  <p>I put the main menu of the program in a different class than the main method. Now I wanted to add a button for an options menu and also put the code it executes into a class of its own, so that in the main menu class I only have to call the options menu method.</p>
  <p>And here I get stuck. If I write the code for the options menu directly in the class of the main menu everything works. But as soon as I outsource the method of the options menu to a separate class, I cannot call the outsourced method.</p>
  <p>Perhaps you can help me.</p>
  <p>Here is the code that shall be performed when hitting the options button:</p>
  <pre><code>public class CPP_Frame extends JFrame {
  
          JButton SettingsButton = new JButton(&quot;Options&quot;);
          SettingsButton.addActionListener(new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
  
                  CPP_Frame OptionsMenu = new CPP_Frame();
                  OptionsMenu.OptionsMenuLoader();
              }
          });
      }
  </code></pre>
  <p>And that´s the code inside the Options Menu-class that shall be called by the 'OptionsMenuLoader':</p>
  <pre><code>public class Options_Menu extends JFrame {
  
      protected void OptionsMenuLoader() {
          CPP_Frame OptionsMenu = new CPP_Frame();
          OptionsMenu.setSize(new Dimension(400, 500));
          OptionsMenu.setVisible(true);
          OptionsMenu.setTitle(&quot;Options&quot;);
          OptionsMenu.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
      }
  }
  </code></pre>
  <p>Where do I mistaken or is the way I try to write the code even possible.
  I hope I´ve explained my problem detailed enough.
  Thanks in Advance.</p>