public void deselect(ArrayList<Point> p, Point start) {
   for (int i = 0; i < p.size(); i++) {
     Point temp = p.get(i);
     tem[temp.getY()][temp.getX()].setClicked(false);
     tem[temp.getY()][temp.getX()].validate();
     tem[temp.getY()][temp.getX()].repaint();
   }
 }
 public void deHighlightButton(ArrayList<Point> p) {
   if (CheckerButton.isOneButtonClicked()) {
     return;
   }
   for (int i = 0; i < p.size(); i++) {
     Point temp = p.get(i);
     tem[temp.getY()][temp.getX()].setHighlighted(false);
     tem[temp.getY()][temp.getX()].validate();
     tem[temp.getY()][temp.getX()].repaint();
   }
 }
 public void perform(ArrayList<Point> p, Point start) {
   if (!CheckerButton.isOneButtonClicked()) {
     deselect(p, start);
     return;
   }
   for (int i = 0; i < p.size(); i++) {
     Point temp = p.get(i);
     tem[temp.getY()][temp.getX()].setClicked(true);
     tem[temp.getY()][temp.getX()].validate();
     tem[temp.getY()][temp.getX()].repaint();
   }
 }
 @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);
         }
       }
     }
   }
 }
 @Override
 public void mouseEntered(MouseEvent arg0) {
   if (RightSidePanel.isNewGameAction()) {
     setVisible(false);
     dispose();
     restart.setVisible(true);
   }
   if (arg0.getSource() instanceof CheckerButton) {
     Object temo = arg0.getSource();
     Point start = ((CheckerButton) temo).getPosition();
     ArrayList<Point> highlighted = game.getPossibleMoves(new Point(start.getY(), start.getX()));
     highlightButton(highlighted);
   }
 }
 public void deSelect(Point start) {
   ArrayList<Point> possibleMoves = game.getPossibleMoves(new Point(start.getY(), start.getX()));
   CheckerButton.setOneButtonClicked(!CheckerButton.isOneButtonClicked());
   perform(possibleMoves, start);
   firstHit = !firstHit;
 }