I ran into an issue while I’m making a 4 player chess game. I am unable to see if two ImageIcons are the same. I have four arrays for the red, blue, green, and yellow pieces and my idea was to see if what piece the player clicked on matched any of the pieces in their color array. However if I say like if(colorIcon.equals(clickedIcon)) it returns false. I know that is because .equals() refers to the reference and I’m making new space in the memory. So is there any way I can compare two ImageIcons? Thanks for reaading!
Share
You can always do:
And use this class instead of a raw ImageIcon
Instead of having:
you would have: