0
我寫了一些代碼像下面試圖顯示一個20圖像的數組,但只得到最後一個圖像顯示。我很困惑,期待你的幫助!使用for循環唯一diaplays最後的圖像
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