Im trying to make a simple board game in which when you click a button its image is set to that of the character you have selected.
This:
board[x][y].setIcon(Soldier.iconImg);
Does not work. It places a tiny white dot on the button and nothing else. The Soldier.iconImg calls for an Icon from the Soldier class.
String name = soldier;
Icon iconImg = new ImageIcon("/Resources/"+name+"Img.png");
Now when i do this:
board[x][y].setIcon(new ImageIcon("/Resources/soldierImg.png"));
It works fine.
I've found a bit of a way around the problem:
board[x][y].setIcon(new ImageIcon("Resources/"+Soldier.name+"Img.png"));
I am however still quite confused as to why the first method doesn't work while the second does. Anybody have any idea?