[code=Java]

public connectFour() {

for (int i = 0; i < ROWSNUM; i++) {

for (int j = 0; j < COLSNUM; j++) {

button[i][j] = new JLabel();

button[i][j].setHorizontalAlignment(SwingConstants.CENTER);

button[i][j].setBorder(new LineBorder(Color.black));

button[i][j].addMouseListener(this);

contentPane.add(button[i][j]);

}

}

}

public void mouseClicked(MouseEvent event) {

// TODO Auto-generated method stub

String player;

for (int row = ROWSNUM - 1; row >= 0; row--) {

for (int col = COLSNUM - 1; col >= 0; col--) {

if (button[row][col] == event.getSource()) {

if (currentPlayer % 2 == 0 && grid[row][col] == 0) {

// button[row][col].setRolloverIcon(p1);

button[row][col].setOpaque(true);

button[row][col].setBackground(Color.red);

player = player1;

currentPlayer++;

if (CheckWhoWin()) {

WinStatue();

JOptionPane.showMessageDialog(null,

"The winner is: " + player);

for (int x = 0; row <= ROWSNUM - 1; x++) {

for (int y = 0; y <= COLSNUM - 1; y++) {

grid[x][y] = 0;

}

}

}

break;

} if (currentPlayer % 2 != 0 && grid[row][col] == 0) {

// button[row][col].setRolloverIcon(p2);

button[row][col].setOpaque(true);

button[row][col].setBackground(Color.yellow);

player = player2;

currentPlayer++;

if (CheckWhoWin()) {

WinStatue();

JOptionPane.showMessageDialog(null,

"The winner is: " + player);

for (int x = 0; row <= ROWSNUM - 1; x++) {

for (int y = 0; y <= COLSNUM - 1; y++) {

grid[x][y] = 0;

}

}

}

break;

} else

JOptionPane.showMessageDialog(null, "ERROR");

break;

}

}

}

}

public boolean CheckWhoWin() {

// Vertically

for (int i = 0; i < 3; i++) {

for (int j = 0; j < 7; j++) {

if (grid[i][j] != 0 && grid[i][j] == grid[i + 1][j]

&& grid[i][j] == grid[i + 2][j]

&& grid[i][j] == grid[i + 3][j]){

winStatue = 1;

win = true;

}

}

}

// horizontally

for (int i = 0; i < 6; i++) {

for (int j = 0; j < 4; j++) {

if (grid[i][j] != 0 && grid[i][j] == grid[i][j + 1]

&& grid[i][j] == grid[i][j + 2]

&& grid[i][j] == grid[i][j + 3]){

winStatue = 2;

win = true;

}

}

}

// positive Diagonal

for (int i = 0; i < 3; i++) {

for (int j = 0; j < 4; j++) {

if (grid[i][j] != 0 && grid[i][j] == grid[i + 1][j + 1]

&& grid[i][j] == grid[i + 2][j + 2]

&& grid[i][j] == grid[i + 3][j + 3]){

winStatue = 3;

win = true;

}

}

}

// negative Diagonal

for (int i = 3; i < 6; i++) {

for (int j = 0; j < 4; j++) {

if (grid[i][j] != 0 && grid[i][j] == grid[i - 1][j + 1]

&& grid[i][j] == grid[i - 2][j + 2]

&& grid[i][j] == grid[i - 3][j + 3]){

winStatue = 4;

win = true;

}

}

}

return win;

}

public void WinStatue(){

for (int i = 0; i < ROWSNUM - 1; i++){

for (int j = 0; j < COLSNUM - 1; j++){

if (winStatue == 1){

button[i][j].setOpaque(false);

button[i + 1][j].setOpaque(false);

button[i + 2][j].setOpaque(false);

button[i + 3][j].setOpaque(false);

}

if (winStatue == 2){

button[i][j].setOpaque(false);

button[i][j + 1].setOpaque(false);

button[i][j + 2].setOpaque(false);

button[i][j + 3].setOpaque(false);

}

if (winStatue == 3){

button[i][j].setOpaque(false);

button[i + 1][j + 1].setOpaque(false);

button[i + 2][j + 2].setOpaque(false);

button[i + 3][j + 3].setOpaque(false);

}

if(winStatue == 4){

button[i][j].setOpaque(false);

button[i - 1][j + 1].setOpaque(false);

button[i - 2][j + 2].setOpaque(false);

button[i - 3][j + 3].setOpaque(false);

}

}

}

}

I dont know what is the error