How to change the state of each cell using a 2D boolean array
I have attached a Jtable code. I like to remove the "oneCount, twoCount..." because overtime there will get unmaintainable as the grid size increases. I would like to keep a 2D Array of boolean values to indicate whether a cell should be highlighted or not. A mouse pressed on the cell would toggle the value. The renderer would check the value do the the highlighting. In my renderer I want to keep a 2D Array to represent the state of each cell. I have a MouseListener and I the row and column of the cell. I want to toggle the state of the cell in the renderer and invoke repaint() on the table. I initialized the 2D boolean array and it should be false by default. When I assign it to true I get the exception "java.lang.ArrayIndexOutOfBounds Exception" boolean cells[][] = new boolean[row][column]; cells[row][column] = true; How should I add a 2D boolean array to change the state of each cell? https://code.sololearn.com/cQ1cVEjne87q/?ref=app