title: Adding a class that extends Canvas to a JPanel doesn't work
body: <p>I know that there are similar questions on SO like <a href="https://stackoverflow.com/questions/37207631/adding-a-canvas-to-a-panel-doesnt-show-the-canvas">here</a>, but none of them have seemed to fix my problem.</p>
  
  <p>So far, I have two classes: a Game class that extends <code>Canvas</code>, and a Window class. All the Window class really does is create the <code>JFrame</code> and the <code>JPanel</code>'s and adds all the necessary components.</p>
  
  <p>One of the components I've been trying to add to the <code>JPanel</code> is the Game class itself. I've passed in a Game (which is a child class of Canvas) to the Window constructor:</p>
  
  <pre><code>public Window(int width, int height, String title, Game game) {
      // ...
  }
  </code></pre>
  
  <p>And, inside the Window constructor, apparently adding the Game to the <code>JFrame</code> itself works:</p>
  
  <pre><code>public Window(int width, int height, String title, Game game) {
      JFrame frame = new JFrame();
  
      // frame.setSize(new Dimension(500,500)); frame.setVisible(true); etc.
      frame.add(game);
  }
  </code></pre>
  
  <p>However, when I try to add the Game to the panel, it won't show!</p>
  
  <pre><code> public Window(int width, int height, String title, Game game) {
       JFrame frame = new JFrame();
       JPanel panel = new JPanel(new GridBagLayout());
  
       panel.setSize(new Dimension(400,500));
       panel.setLocation(0,0);
       panel.requestFocus();
       panel.setVisible(true);
  
       frame.setSize(500, 500);
       frame.setResizable(false);
       frame.setLocationRelativeTo(null);
       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
       frame.setTitle(title);
  
       frame.setVisible(true);
  
       GridBagConstraints gbc = new GridBagConstraints();
       panel.add(game, gbc); // doesn't work
       frame.add(panel);
   }
  </code></pre>
  
  <p>If you're wondering why I don't just add Game (which again extends Canvas) to the <code>JFrame</code> itself, it's because I want to add more panels to the frame - and I don't want the panel to be the full size of the window. Adding Game to the panel would make life a <em>whole</em> lot easier because then I can have other panels within the window.</p>