   array loop problem in java
  I'm remaking a Master Mind game, and I want the player to choose what color their guess is through 4 buttons.  Each button should run through the 6 possible colors, and set that color as the background.  When the submit button is pressed the computer should check the 4 colors, and compare it to the 4 colors that was generated, and i'm sure you know the game blah blah blah.  I'm having trouble with the four buttons running through all 6 possible colors, then setting that 1 color to that button.  I have the code below, but on the first set of buttons it only hits 3 different colors.  Why?, or is there a much easier way of doing this?countFlag starts at 0, and increases by one everytime submit button is pressed.Therefore, if I can get this code to work, my game will be complete, the small AI is already done.for(int i=0; i<=3; i++)   {    if(e.getSource() == Play[countFlag])  {    colorcounter++; //color counter to click through possible array which is the array that holds all colors in the game.    thisbutton = i; //present button that is being pressed.    change();   //method to go to to change color.  if(colorcounter>=6)colorcounter=0;    //if colorcounter is greater than what possible colors we have set it back to 0.    }} public void change()    { for(int b=0; b<=thisbutton; b++)//loop for determing what btn is pressed   for(int a=1; a<=colorcounter; a++)//loop for color_code increases everytime button is pressed.   for(int c=0; c<=3; c++)//here only to compare where isPressed is during the loop. {   if(c==thisbutton)Play[countFlag][c].setBackground(possible[a-1]);   guess[thisbutton] = Play[0][thisbutton].getBackground();    }    }um.. maybe their is an easier way to code this if ya know one, please let me know.  thanxbionic_atom