title: Adding oval shape to JPanel
body: <p>Here's my simple code. I don't really know how to add a drawn oval to a <code>JPanel</code>. I did some paintings before, but I have never used the constructor so I don't have an idea.</p>
  
  <pre><code>public class Buffer extends JPanel{
      public JFrame frame;
      public JPanel panel;
  
      public Buffer(){
          frame=new JFrame();
          panel=new JPanel();
  
          panel.setSize(500,500);
          panel.setBackground(Color.red);
  
          frame.setSize(500,500);
          frame.setVisible(true);
          frame.add(panel);
      }
  
      public void paintComponent(Graphics g){
          super.paintComponents(g);
          g.fillOval(20,20,20,20);
      }
  
      public static void main(String args[]){
          new Buffer();
      }
  }
  </code></pre>