title: How to make an app using swing that only uses 1 JFrame?
body: <p>I am making an app or (something.exe). I want to make a class that will serve as my main frame. That is because I don't want to create new frame for each class that I will make. I want my class <code>MainMenu</code> to have the Frame of <code>MainFrame</code> where I can put buttons and etc.</p>
  <pre><code>package ThinkNotOfficial;
  
  public class Main {
  
      public static void main(String[] args) {
  
          MainFrame mainFrame = new MainFrame();
  
      }
  }
  </code></pre>
  <pre><code>package ThinkNotOfficial;
  
  import javax.swing.*;
  import java.awt.*;
  
  public class MainFrame extends JFrame{
  
      // Global Variables
      JFrame mainFrame = new JFrame(&quot;Base Frame (global)&quot;);
      ImageIcon logo = new ImageIcon(&quot;Logo.png&quot;);
  
      MainFrame (){
          mainFrame.setSize(500, 500);
          mainFrame.setResizable(false);
          mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          mainFrame.setIconImage(logo.getImage());
          mainFrame.getContentPane().setBackground(new Color(255,255,255));
          mainFrame.setLocationRelativeTo(null);
          mainFrame.setLayout(null);
  
          mainFrame.setVisible(true);
  
          // ------------ PROGRAM FIELD -----------
  
  
  
      }
  }
  </code></pre>
  <pre><code>package ThinkNotOfficial;
  
  import javax.swing.*;
  
  public class MainMenu{
  
      // ------------ Global Variables ------------
      JButton play = new JButton(&quot;PLAY&quot;);
  
      MainMenu(){
          // ------------ PLAY button ------------
          play.setSize(100,50);
  
          // ------------ Adding parts ------------
  
      }
  }
  </code></pre>