title: One unnecessary turn in TicTacToe game
body: <p>I'm trying to make this code for a TicTacToe game in JavaFX. But now even when there is a winner (meaning someone put his three Xs or Os in a row/column/diagonal) the programme still allows the other player to put his sign on the board. Only after that the winning buttons are changed and the buttons are set disabled. How do I change that?</p>
  
  <pre><code>package tictactoe;
  
  import javafx.collections.ObservableList;
  import javafx.event.ActionEvent;
  import javafx.fxml.FXML;
  import javafx.scene.Node;
  import javafx.scene.control.Button;
  import javafx.scene.control.MenuItem;
  import javafx.scene.layout.GridPane;
  
  public class TicTacToeController {
  private boolean isFirstPlayer = true;
  
  public void buttonClickHandler(ActionEvent evt) { 
      this.find3InARow();  
  
      Button clickedButton = (Button) evt.getTarget();
      String buttonLabel = clickedButton.getText();
  
      if ("".equals(buttonLabel) &amp;&amp; isFirstPlayer){
          clickedButton.setText("X");
          isFirstPlayer = false;
      } else if("".equals(buttonLabel) &amp;&amp; !isFirstPlayer) {
          clickedButton.setText("O");
          isFirstPlayer = true;
      }
  
  }
  @FXML Button b1; 
  @FXML Button b2;
  @FXML Button b3;
  @FXML Button b4;
  @FXML Button b5;
  @FXML Button b6;
  @FXML Button b7;
  @FXML Button b8;
  @FXML Button b9;   
  @FXML GridPane gameBoard;
  @FXML MenuItem Play; 
  
  private boolean find3InARow() {
      if (""!=b1.getText() &amp;&amp; b1.getText() == b2.getText() 
          &amp;&amp; b2.getText() == b3.getText()){
          highlightWinningCombo(b1,b2,b3);
          return true; 
      }
  
      if (""!=b4.getText() &amp;&amp; b4.getText() == b5.getText() 
          &amp;&amp; b5.getText() == b6.getText()){
          highlightWinningCombo(b4,b5,b6);
          return true; 
      }
  
      if (""!=b7.getText() &amp;&amp; b7.getText() == b8.getText() 
          &amp;&amp; b8.getText() == b9.getText()){
          highlightWinningCombo(b7,b8,b9);
          return true; 
      }
  
      if (""!=b1.getText() &amp;&amp; b1.getText() == b4.getText() 
          &amp;&amp; b4.getText() == b7.getText()){
          highlightWinningCombo(b1,b4,b7);
          return true; 
      }
  
      if (""!=b2.getText() &amp;&amp; b2.getText() == b5.getText() 
          &amp;&amp; b5.getText() == b8.getText()){
          highlightWinningCombo(b2,b5,b8);
          return true; 
      }
  
      if (""!=b3.getText() &amp;&amp; b3.getText() == b6.getText() 
          &amp;&amp; b6.getText() == b9.getText()){
          highlightWinningCombo(b3,b6,b9);
          return true; 
      }
  
      if (""!=b1.getText() &amp;&amp; b1.getText() == b5.getText() 
          &amp;&amp; b5.getText() == b9.getText()){
          highlightWinningCombo(b1,b5,b9);
          return true; 
      }
  
      if (""!=b3.getText() &amp;&amp; b3.getText() == b5.getText() 
          &amp;&amp; b5.getText() == b7.getText()){
          highlightWinningCombo(b3,b5,b7);
          return true; 
      }
      return false;
  
      }
  
      private void highlightWinningCombo(Button first, Button second, Button third) {
          gameBoard.setDisable(true);
          first.getStyleClass().add("winning-button");
          second.getStyleClass().add("winning-button");
          third.getStyleClass().add("winning-button");
      }
  
      public void menuClickHandler(ActionEvent evt){
          MenuItem clickedMenu = (MenuItem) evt.getTarget();
          String menuLabel = clickedMenu.getText();
  
          if ("Play".equals(menuLabel)){ 
              ObservableList&lt;Node&gt; buttons =  gameBoard.getChildren(); 
  gameBoard.setDisable(false);
  
              buttons.forEach(btn -&gt; { 
                  ((Button) btn).setText("");  
                  btn.getStyleClass().remove("winning-button");
              });
              isFirstPlayer = true;  
          }
          else if("Quit".equals(menuLabel)) {
              System.exit(0);
     }
  
      }
  </code></pre>
  
  <p>}</p>