title: Dynamically update Combobox after selecting item in another ComboBox - JavaFX
body: <p>I have a JavaFX form with two combo boxes populated with Times in 15 min increments for Start and End times. I am trying to get the End time combo box to dynamically repopulate with options when the user selects a start time so that it is not possible for the user to select an End time before the start time while preserving the user's selection if the user has already selected an end time that is still after the start time. </p>
  
  <p>I have been able to get both boxes to populate correctly and correctly retain the user's selection when testing that the code works, however, I cannot get an event to fire correctly for when the user selects a new start time. If I use the onMouseClicked it fires the event when you click on the combo box not when you make a selection, it will work if using the onMouseExit event, but after an annoying delay. </p>
  
  <p>How can I get this even to fire correctly when an item in the ComboBox is selected?</p>
  
  <p>FXML</p>
  
  <pre><code> &lt;ComboBox id="Start Dropdown" fx:id="cbStart" onMouseClicked="#handleSelectStart" prefWidth="150.0" GridPane.columnIndex="5" GridPane.rowIndex="4"&gt;
         &lt;GridPane.margin&gt;
            &lt;Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /&gt;
         &lt;/GridPane.margin&gt;
   &lt;/ComboBox&gt;
   &lt;ComboBox id="End Dropdown" fx:id="cbEnd" prefWidth="150.0" GridPane.columnIndex="8" GridPane.rowIndex="4"&gt;
         &lt;GridPane.margin&gt;
            &lt;Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /&gt;
         &lt;/GridPane.margin&gt;
   &lt;/ComboBox&gt;
  </code></pre>
  
  <p>Controller method called when handleSelectStart is called by the action listener</p>
  
  <pre><code>@FXML
  private void handleSelectStart(MouseEvent event){
      //Get the currently selected Start time from Start ComboBox
      LocalTime time = LocalTime.parse(cbStart.getValue(), timeDTF);
  
      //Store the current Selected End time for later comparison
      String currentEnd = cbEnd.getSelectionModel().getSelectedItem();
  
      //Clear out existing options from End Combo Box ObservableList
      availEndTimes.clear();
  
      do{
          availEndTimes.add(time.format(timeDTF));
          time = time.plusMinutes(15);
      } while(!time.equals(LocalTime.of(17, 15)));
  
      availEndTimes.remove(0);
  
      if(availEndTimes.contains(currentEnd)){
         cbEnd.setItems(availEndTimes);
         cbEnd.getSelectionModel().select(currentEnd);
         //setValidEndTimes();
      } else {
         cbEnd.setItems(availEndTimes);
         cbEnd.getSelectionModel().select(availEndTimes.get(0));
      }
  }
  </code></pre>
  
  <p>I am sure I am missing something obvious and simple but I cannot seem to see it. If I missed another question I apologize for the duplicate question but I looked through several articles here and on other sites without figuring it out. Any assistance would be greatly appreciated.</p>