I have a class that creates a frame.
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;
}
If I have another class that would add Panels and Buttons to the frame, how can I add them? I have tried:
GameDisplay g;
Container c;
c = g.getFrame().getContentPane();
But it returns NullPointer Error. Thus, I can't seem to add panels to it.
 
    