Is there a way I can stick this into a for loop? [JAVA] : is there anyway that I can stick this in a for loop??? This is part of the logic for a ticTacToe game, I am checking the button clicked via ActionListener, then I am checking for a boolean value, and thats how I determine wether to place an X or O.

    if(src == b1){
       if(firstPlayer){
          b1.setIcon(playerO);
          firstPlayer = false;
       } else {
          b1.setIcon(playerX);
          firstPlayer = true;
       }
    }

I want to change the b1 to b2, b3, b4, and so on until I get to b9. I have nine buttons that i need to check. 3X3 grid. Right now, I have copied and pasted this 9 times, then I changed the button to the one I need, but thats bad practice, and the code is repetitive. 

Thanks in advanced!