I am making a chess board. Each space is represented by a JLabel. When the user clicks the JLabel, I would like to color the squares around it with the possible moves. This is done by one of my methods that is passed the x, y position of the piece on the space clicked. I figured I would do this by setting the .setActionCommand of each of to "00", "01", "02", etc. This way before I needed to pass they x and y, I could check the .setActionCommand value for the coords. Well, apparently, JLabels do not have this method like JButtons do. I see JLabels have .setActionMap, but I dont know this method is meant to work the same as .setActionCommand.
So my question is, is there I was I can sort of 'mark' my JLabels with its coord so when it is clicked I can check it (many JLabels will use the same Listener)?
Try the Component method get/setName or the JComponent method get/setClientProperty.