So, im working on my slide puzzel game, which have 16 JButtons in a gridlayout. 15 of them have a number 1-15 and the last one is empty. I have now written the code for the gui and everything except the public void actionPerformed(ActionEvent e). This is how it looks:(the gui)
https://i.stack.imgur.com/rbTt6.jpg
(Sorry for not posting picture here, I cannot do that since I dont have enough reputation)
For example, when i click the "4" button, it should change like it did in the picture to the right. To change this, I know how to, but to check horizontally and vertically if the "empty button" is next to it I have no idea how to. Ive tried to google it, but I havnt found anything to help me. How should I do this? I am not asking for you guys to write code for me, no, I am asking how should I tackle this problem?
THank you