I am making a game called Light out! I would like to create a method that changes the color of a button at a certain index. to do this, ive used the following code:
Color bg = _buttons[x][y].getBackground();
if(bg.equals(Color.white)){
_buttons[x][y].setBackground(Color.yellow);
}
else if (bg.equals(Color.yellow)){
_buttons[x][y].setBackground(Color.white);
x and y are integers that are the currant value I am looking at. basically I would like to make a method that takes in whatever index I am at. I tried doing
public void flipIt(JButton _buttons[this] [this]){
Color bg = _buttons[this][this].getBackground();
}
but java doesnt like that, can anyone point me in the right direction please?
xandyintegers)flipIt(). In that function, the button would bethis, and thex,ywould not be referenced at all.