@Override public void mouseClicked(MouseEvent arg0) { Object temo = arg0.getSource(); Point start = ((CheckerButton) temo).getPosition(); if (game.getTurn() == game.getColor(new Point(start.getY(), start.getX()))) { if (firstHit) { ArrayList<Point> possibleMoves = game.getPossibleMoves(new Point(start.getY(), start.getX())); clickedPoint = start; CheckerButton.setOneButtonClicked(!CheckerButton.isOneButtonClicked()); perform(possibleMoves, start); firstHit = !firstHit; return; } else { if (clickedPoint.compareTo(start) == 0) { deSelect(start); return; } } } else { if (game.move( new Point(clickedPoint.getY(), clickedPoint.getX()), new Point(start.getY(), start.getX()))) { back(); tem = new CheckerButton[8][8]; updateBoard(); if (game.isGameOver()) { if (game.getWinner() == 1) { JOptionPane.showMessageDialog( null, game.getWhitePlayer().getName() + " Wins !!", "Congratulations", JOptionPane.PLAIN_MESSAGE); } else { JOptionPane.showMessageDialog( null, game.getBlackPlayer().getName() + " Wins !!", "Congratulations", JOptionPane.PLAIN_MESSAGE); } int x = JOptionPane.showConfirmDialog( null, "Do you want to play again ??", "Confirmation Message", 0); if (x == 0) { this.setVisible(false); restart.setVisible(true); } else { System.exit(0); } } } } }