0

Not sure how to use counter variables for my event handler. I get the error that says it's not final. I understand that it does not work because after an iteration of the for loop, the variable is incremented. But how can I work around that?

Tile[][] tiles = board.getTileArray(); 

Button b = (Button)getNodeFromGridPane(grid, i, j);
b.setOnAction(
    new EventHandler<ActionEvent>(){
        public void hand(ActionEvent e){
            tiles[i][j] = Tile.BLACK;
            }
    });

0 Answers0