Im building a board using GUI(may be board game). I have created 2D array to make cells like Gomoku game. I want to make this function: Whenever i click a cell, the cell position will be displayed.
private Cell[][] cells;
private in row;
private int col;
Update:
.......
JPanel pn = new JPanel(new GridLayout(row, col, 0, 0));
cells = new Cell[row][col];
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
pn.add(cells[i][j] = new Cell());
}
......
private class MouseListener extends MouseAdapter {
public void mouseClicked(MouseEvent e) {
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
if ( ) {
System.out.println("X: " + i + ", Y: " + j);
}
}
}
}
I cant make it work although i've tried several times and different conditions in if