title: New to java can't figure out how to use paint method
body: <p>I am trying to learn the paint method and get a ball to move across the frame. here is my code so far. w=.</p>
  
  <p>I currently have two classes One is the main and one for the ball.</p>
  
  <p>this is the main class
      import java.awt.<em>;
      import javax.swing.</em>;</p>
  
  <pre><code>public class PaintTest extends JPanel {
  int x = 0;
  int y = 0;
  
  public void moveBall(){
      x = x + 1;
      y = y + 1;
  }
  public static void main(String[] args){
      JFrame frame = new JFrame();
      frame.setSize(500,500);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setVisible(true);
  
      Ball ball = new Ball(x,y);
  
      while(true){
          ball.moveBall();
          repaint();
      }
      }
  protected void paintComponent(Graphics g){
      super.paintComponent(g);
  
      Graphics2D g2 = (Graphics2D) g;
  
      g.setColor(Color.magenta);
      g.drawLine(0,100,500,100);
      g.drawLine(0,101,500,101);
      g.drawLine(0,102,500,102);
      g.drawLine(0,103,500,103);
  
      g2.fillOval(x,y,35,35);
  }
  }
  </code></pre>
  
  <p>and here is the ball class</p>
  
  <pre><code> public class Ball {
  
     int x,y;
  
     public Ball(int x, int y){
  this.x = x;
  this.y = y;
  }
  }
  </code></pre>
  
  <p>now when i compile I get an error saying cannot find symbol ball in class PaintTest even though I am calling it from the class Ball. I am aware of the repaint error as i do not know what to put in front of it.</p>