@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);
         }
       }
     }
   }
 }
  public void updateBoard() {
    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {

        tem[i][j] = new CheckerButton(game.getColor(new Point(j, i)), x, y, new Point(i, j));

        tem[i][j].addMouseListener(this);
        x += WIDTH;
        gamePanel.add(tem[i][j]);
      }
      y += HEIGHT;
      x = 0;
    }
    firstHit = true;
    x = 0;
    y = 0;
    gamePanel.validate();
    gamePanel.repaint();
    rightPanel.validate();
    rightPanel.repaint();
  }