I can currently add different labels based on their class type to a gridpane while iterating though an array. How would I be able to do this, but with certain images instead? I.e if the object in the array is of type: Class 1, then add the image banana.png
Here's the code I am currently using to add labels:
for (int x = 0; x < Array.length; x++) {
for (int y = 0; y < Array[x].length; y++) {
Label labelName;
if (Array[x][y] instanceof Class1) {
labelName = new Label("Class1");
else {
labelName = new Label(Class2");
}
theGrid.add(labelName, x, y);