0
次のようなコードを書いて、20個の画像の配列を表示しようとしましたが、最後の画像しか表示されませんでした。私は大きな混乱とあなたの助けを楽しみにしています!forループのみを使用すると、最後の画像が表示されます
String []img={"a.png","b.png","c.png"...20 more};
for(int x=0;x<20;x++)
{
images[x]=new Image(img[x]);
views[x]=new ImageView(images[x]);
//put the images in the buttons on GridPane
for(int i=0;i<4;i++){//row
for(int j=0;j<5;j++){//column
buttons[5*i+j]=new Button();
buttons[5*i+j].setGraphic(new ImageView(images[x]));
gridPane.add(buttons[5*i+j], j, i);
buttons[5*i+j].setPrefHeight(120);
buttons[5*i+j].setPrefWidth(120);
}
}
}
あなたはとてもcoooolだ!! – Yong