I’m writing a board game with a GUI and basically I have a 10×10 GridLayout JPanel.
Each grid cell is a square JPanel (I used BorderLayout for these JPanels so the borders are visible).
Anyway I want it so that when one of these squares is clicked, it makes a change to the boardGameGrid which is a class imported to the GUI for the backend of the game. Say I want to use the method
boardGameGrid.setCellCross(x,y)
when the cell at position (x,y) is pressed.
I can’t figure out how to do this since each JPanel does not contain any information about its position.
thanks
You have to prepare this JPanels as Object and put that to the Map or List, simple example based on great but simple idea