I am trying to make a chess application, currently i can create the chess board using JPanels in an 8x8 grid, and initialize the chess pieces on the board after implementation. My current problem is figuring out a way to move the images using mouse listeners. In the process figuring this out, i managed to switch the image from one to another as an experiment but this was a semi success as it only did it one way and couldn't change it back.
This lead to me realising the best way to do this is to retrieve the fill path as a string from the image.
My Question: Is there a way to retrieve the file path from the image, or would it be best to have the file path stored within the chess piece classes as a string and change the image using retrieved string?