public void buttonPress(int row, int col) { tttBoard.setMark(row, col); if (tttBoard.getMark(row, col) == TicTacToe.mark.XMARK) { button[row][col].setLabel("X"); } else if (tttBoard.getMark(row, col) == TicTacToe.mark.OMARK) { button[row][col].setLabel("O"); } if (tttBoard.checkForWin() == TicTacToe.mark.XMARK) { ActionListener taskPerformer = new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog( null, "X is the winner!", "Game Over", JOptionPane.INFORMATION_MESSAGE); } }; } else if (tttBoard.checkForWin() == TicTacToe.mark.OMARK) { ActionListener taskPerformer = new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog( null, "O is the winner!", "Game Over", JOptionPane.INFORMATION_MESSAGE); } }; } if (tttBoard.checkForTie()) { ActionListener taskPerformer = new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog( null, "Nobody wins! You're equally good.", "Game Over", JOptionPane.INFORMATION_MESSAGE); } }; } }