title: Timer with paint Component
body: <p>I am trying to paint circles onto my panel but the colour of the circle is determined by some parameters. Firstly the circles should be painted as white then go into a for loop checking which paramater matches and should paint the circle in that colour. the location of the circles are stored in an array. my code i have done so far does not work. i am clearly doing something wrong but i am new to java and coding so i am very stuck. if someone could show me how to edit/change my code i would really appreciate it. ArrayList circlesT is an arraylist of the circles locations and temp is the array with values i have the parameters too.</p>
  
  <pre><code>public void paintComponent(Graphics g) {            
          drawShapes(g, circlesT);          
      }           
  
      public void drawShapes(Graphics g, final ArrayList&lt;Shape&gt; circlesT) {
          final Graphics2D ga = (Graphics2D) g;
          ga.drawImage(newImage, 0, 0, null);
          for (int i = 0; i &lt; circlesT.size(); i++) {
              ga.draw(circlesT.get(i));
              ga.setPaint(Color.white);
              ga.fill(circlesT.get(i));
          }    
          Timer timer = new Timer();
          TimerTask t;
          t = new TimerTask() {
              @Override
              public void run() {
                  for (int i = 0; i &lt; 10; i++) { 
                      if (read.temp.get(i) &lt; 31 &amp;&amp; read.temp.get(i) &gt; 30) {
                          ga.draw(circlesT.get(i));
                          ga.setPaint(Color.green);
                          ga.fill(circlesT.get(i));
                      } else if (read.temp.get(i) &lt; 32 &amp;&amp; read.temp.get(i) &gt; 31) {
                          ga.draw(circlesT.get(i));
                          ga.setPaint(Color.red);
                          ga.fill(circlesT.get(i));
                      } else if (read.temp.get(i) &lt; 33 &amp;&amp; read.temp.get(i) &gt; 32) {
                          ga.draw(circlesT.get(i));
                          ga.setPaint(Color.yellow);
                          ga.fill(circlesT.get(i));
                      }                 
                  }                    
              }
          };
          //repaint();
          timer.schedule(t, 0, 1000);    
      }
  </code></pre>