PDA

View Full Version : [Risolto]JAVA Matrice


Pro7on
04-06-2007, 16:13
cosė creo 15 button



JButton[] btn = new JButton[15];


for(int x=0;x<15;x++){

btn[x] = new JButton("btn"+x);

}


come faccio a crearne 15*15?

xche questo nn mi va...????:confused:


JButton[] btn = new JButton[15][15];


for(int y=0;y<15;y++){
for(int x=0;x<15;x++){

btn[x][y] = new JButton("btn"+x+y);

}
}

andbin
04-06-2007, 16:29
xche questo nn mi va...????:confused:
JButton[] btn = new JButton[15][15];


for(int y=0;y<15;y++){
for(int x=0;x<15;x++){

btn[x][y] = new JButton("btn"+x+y);

}
}Solo una cosa non va: se l'array č bidimensionale, devi dichiararlo come tale!
JButton[][] btn = new JButton[15][15];

Pro7on
04-06-2007, 16:53
asd che nubbo.....:muro:

thx ;)