I have a question about a 2-D array of buttons.
I defined 9 buttons and I defined a 2-D array of buttons and I put these 9 buttons to the 2-D array of button;
JButton [] [] Buttons = {{button1, button2, button3},
{button4, button5, button6},
{button7, button8, button9}};
And now I can change the text of button1 in this way:
Button1.setText (“some thing”);
But I can not change it in this way:
for(int i=0 ; i<3 ; i++){
if (Board[i][0]+Board[i][1]==8 && Board[i][2]==0){
Board[i][2] = 4;
Buttons[i] [2].setText("O");
return;
}
}
Why? And what should I do if I want to change the button’s text through the array ?
2007-08-24
00:58:39
·
2 answers
·
asked by
shayan k
1
in
Programming & Design