title: netbeans: animate circle drawn using drawline funtion
body: <p>I am trying to draw a circle like this: <a href="http://35.197.37.158/Circle/" rel="nofollow noreferrer">http://35.197.37.158/Circle/</a></p>
  
  <p>using drawline function and animate it same as the attached link. </p>
  
  <p>here is what I tried but it draw a line of circle and delete the previous one </p>
  
  <p>This is the class that have my code for drawing a circle and animating it using swin Timer. anyone have better idea to animate the circle ?</p>
  
  <pre><code>import java.awt.Color;
  import java.awt.*;
  import java.awt.event.*;
  import java.awt.geom.GeneralPath;
  import javax.swing.*;
  
  public class CustomPanel extends JPanel implements ActionListener{
           Point [] coordinates;
           GeneralPath circle;
          final int C = 10;
          int j =0;
          int i =j;
          Point p;
          Point p2 ;
          Timer clock = new Timer(100, this);
  
  public CustomPanel()
  {
      LinesCoordinates();  
      clock.setInitialDelay(50);
       clock.start();
  }
  
  
   private void LinesCoordinates()
  {        
      int numberOfLines = 360/C;
      coordinates = new Point[numberOfLines];
      double cx = 200.0;
      double cy = 200.0;
      double r = 75.0;
      int count = 0;
      for(int theta = 0; theta &lt; 360; theta+=C)
      {
          int x = (int)(cx + r * Math.cos(Math.toRadians(theta)));
          int y = (int)(cy + r * Math.sin(Math.toRadians(theta)));
          coordinates[count++] = new Point(x, y);
      }
  }
  
  
   @Override
  public void actionPerformed(ActionEvent e) {
      Redraw();
      repaint(); 
      }
  
  public void Redraw(){
      j=j+1;
      p = p2;
  }
  
  @Override
  protected void paintComponent(Graphics g)
  {
      super.paintComponent(g);
      Graphics2D g2 = (Graphics2D)g;
      g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                          RenderingHints.VALUE_ANTIALIAS_ON);
      g2.setPaint(Color.red);
     // while (j&lt;=coordinates.length){
  
     while(i&lt;=j){
     j--;
      p2 = coordinates[j % coordinates.length];
      g2.drawLine(p.x, p.y, p2.x , p2.y);
  
     }}}
  </code></pre>
  
  <p>And this is my Main </p>
  
  <pre><code>public static void main(String[] args)
      {
          // SwingUtilities.invokeLater(new Runnable() {
             // public void run() {
                  JFrame frame = new JFrame("Circle ");
                  CustomPanel co = new CustomPanel();
                  frame.add(co);
                  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                  frame.setSize(300, 300);
                  frame.setVisible(true);
  }
  </code></pre>