title: How to call the JFrame from another class?
body: <p>I have a class that creates a frame.</p>
  
  <pre><code>public class GameDisplay{
  
  ....
  
  public void createDisplay(){
      frame=new JFrame(title);
      canvas=new Canvas();
      canvas.setPreferredSize(new Dimension(width,height));
      canvas.setFocusable(false);
      frame.setSize(width,height);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setLocationRelativeTo(null);
      frame.setVisible(true);
      frame.setResizable(false);
      frame.add(canvas);
      frame.pack();
  }
  public Canvas getCanvas(){
      return this.canvas;
  }
  
  public JFrame getFrame(){
      return frame;
  }
  </code></pre>
  
  <p>If I have another class that would add Panels and Buttons to the frame, how can I add them?
  I have tried:</p>
  
  <pre><code>GameDisplay g;
  Container c;
  c = g.getFrame().getContentPane();
  </code></pre>
  
  <p>But it returns NullPointer Error. Thus, I can't seem to add panels to it.</p>