title: Extending JPanel or returning JPanel
body: <p>I'm currently trying to recreate Breakout and was wondering how to implement basic gui. My structure is a JFrame that contains a JPanel and the JPanel is what actually hold the game's elements. The JFrame gets this JPanel by adding it to it's content pane [frame.getContentPane().add(myPanel)].</p>
  
  <p>My question is, should the class that holds the game's elements extend JPanel or simply return a JPanel?</p>
  
  <pre><code>public class myPanel {
      private JPanel panel;
      public myPanel() {
          panel = new JPanel();
          //do stuff with the panel
      }
  
      public JPanel getPanel() {
          return panel;
      }
  }
  
  public class myPanel extends JPanel{
      public myPanel() {
          panel = new JPanel();
          //do stuff with the panel
      }
  }
  </code></pre>