title: how to change color of Circle in every second
body: <pre><code>import java.applet.*;
  import java.awt.*;      // Graphics, Shape
  import java.awt.geom.*; //Graphics2D
  /*
  &lt;applet code = Oval1.class height=300 width=300 &gt;
  &lt;/applet&gt;
  */
  public class Oval1 extends Applet implements Runnable {
      Shape circle;
      Color c;
      public void init() {
          circle = new Ellipse2D.Float(90,100, 90, 90);
          repaint();
          Thread th = new Thread(this);
          th.start();
      }
      public void run() {
          try {
              while(true) {
                  System.out.println(1);
                  c = Color.cyan;
                  repaint();
                  Thread.sleep(1000);
                  System.out.println(2);
                  c = Color.gray;
                  repaint();
              }
          } catch (Exception ex) {
              ex.printStackTrace();
          }
      }
      public void update(Graphics g) {
          paint(g);
      }
      public void paint(Graphics g) {
          Graphics2D d = (Graphics2D) g;
          d.setColor(c);
          d.fill(circle);
      }
  }
  </code></pre>
  
  <p>I am trying to create an applet that has a filled circle in middle of the applet &amp; changing the color of circle in every second, means I want to show the circle like it's blinking.</p>
  
  <p>I want to change color of circle in every second.</p>
  
  <p>For this I use Shape class &amp; Thread, but it's still not working.</p>
  
  <p>I already try by using  <code>paint(g)</code> by overriding update method..</p>
  
  <p>This will not also effect</p>