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