title: Looping through colours in a window
body: <p>I'm a beginner in Java programming and have come across an issue (probably an easy one to solve).</p>
  
  <p>I am experimenting with Java GUI and wish to create a window in which the colours of an array are cycled through until there are no more colours. I believe I can do this using a for loop and cycling through the array, however I do not know how to loop through the background colour.</p>
  
  <p>Any help and explanation would be appreciated.</p>
  
  <pre><code>public void flashColor()  { 
  
      Color [] color = { Color.red,Color.orange,Color.green };
  
      int i = 0;
      for(i=0;i&lt;color.length;i--){
  
          getContentPane().setBackground(Color(i));
      }
  }
  </code></pre>