java swing associating JPanel with row col values for mouse listener
-
06-11-2019 - |
Question
I'm writing a board game with a GUI and basically I have a 10x10 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
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow