public void refreshAllCells(CellPanel cellPanel) { int cellRow = cellPanel.get().getPosition().getRow(); int cellCol = cellPanel.get().getPosition().getCol(); if (cellPanel.isHidden()) { decreaseUnClickedCells(); cellPanel.display(); if (cellPanel.get() instanceof EmptyCell) { for (int i = Math.max(0, cellRow - 1); i < Math.min(cellRow + 2, rows); i++) for (int j = Math.max(0, cellCol - 1); j < Math.min(cellCol + 2, cols); j++) { CellPanel cp = (CellPanel) this.getComponent(i * this.cols + j); if (!(cp.get() instanceof MineCell)) refreshAllCells(cp); } } } }