title: Java repaint() method issue. Repainting JPanel will disappear painted components in JFrame
body: <p>I created a separate class for JFrame and JPanel, then draw (fillOval in a JFrame class) and draw (fillOval in a JPanel class), and a button that will just animate the JPanel components. But the problem is, whenever i repaint the JPanel class; ---- The JFrame components disappeared. I don't understand why is this happening. I want the JFrame component be permanent for every animation done in JPanel class.</p>
  
  <p>Sample Code:</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  import java.awt.event.*;
  
  public class TryRepaintIssue extends JFrame
  {
      public TryRepaintIssue(){
         thePanel panel = new thePanel();
         add(panel);
         setSize(1000,1000);
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         setVisible(true);
      }
  
      public void paint(Graphics g){
          super.paint(g);
          g.fillOval(100,500,100,100);
      }
      public static void main(String[] args){
          new TryRepaintIssue();
      }
  
      public static class thePanel extends JPanel{
          private int y = 100, vector = 1;
          public thePanel(){
              JButton button = new JButton("Play");
              button.addActionListener(new ActionListener(){
                  public void actionPerformed(ActionEvent ae){
                      y += vector;
                      repaint();
                  }
              });
              add(button);
          }
          public void paintComponent(Graphics g){
              super.paintComponent(g);
              Graphics2D g2 = (Graphics2D) g;
              g2.setColor(Color.red);
              g2.fillOval(100,y,100,100);
          }
      }
  }
  </code></pre>