i have an array of JLabel and i have arranged them like
1 2 3
4 5 6
7 8 9
and added .addmouselistener to them but am not sure how to make it so that when i click 2 it will be not do anything and after clicking 2, i clicked 1 they will swap. its like picking 2 jlabel and checking if they can be swapped and if yes, then swap and if no pick another 2.
also how can i get the n in jlabel[n] if its been clicked.