title: Update labels in JavaFX after selecting comboBox value
body: <p>I am trying to update labels in JavaFX upon selecting a value from the combobox.  The value in the comboBox represents an array object.  When I  load the page for the first time and select an option, it updates successfully.  However, when I select a different value in the comboBox the labels do not update.  Can anyone suggest why this might be?</p>
  
  <pre><code>package controllers;
  
  import java.net.URL;
  import java.util.ResourceBundle;
  
  import app.TreatmentRoom;
  import javafx.collections.FXCollections;
  import javafx.collections.ObservableList;
  import javafx.event.ActionEvent;
  import javafx.fxml.FXML;
  import javafx.fxml.FXMLLoader;
  import javafx.fxml.Initializable;
  import javafx.scene.Node;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.scene.control.ComboBox;
  import javafx.scene.control.Label;
  import javafx.stage.Stage;
  
  public class DoctorAssessmentPageController implements Initializable {
  
    @FXML
    private ComboBox&lt;String&gt; comboBox;
    @FXML
    private Label nhsNumberLabel;
    @FXML
    private Label titleLabel;
    @FXML
    private Label firstNameLabel;
    @FXML
    private Label lastNameLabel;
  
    ObservableList&lt;String&gt; list = FXCollections.observableArrayList("Treatment Room 1", "Treatment Room 2",
        "Treatment Room 3", "Treatment Room 4", "Treatment Room 5");
  
    @Override
    public void initialize(URL location, ResourceBundle resources) {
      comboBox.setItems(list);
    }
  
    @FXML
    private void buttonActionConfirmRoom(ActionEvent event) {
      switch (comboBox.getValue()) {
      case ("Treatment Room 1"):
        setPatientInfo(0);
        break;
      case ("Treatment Room 2"):
        setPatientInfo(1);
        break;
      case ("Treatment Room 3"):
        setPatientInfo(2);
        break;
      default:
        System.out.println("treatment room not recognised");
      }
  
    }
  
    public void setPatientInfo(int i) {
      nhsNumberLabel.setText(TreatmentRoom.treat[i].getPatient().getNhsNumber());
      titleLabel.setText(TreatmentRoom.treat[i].getPatient().getTitle());
      firstNameLabel.setText(TreatmentRoom.treat[i].getPatient().getFirstName());
      lastNameLabel.setText(TreatmentRoom.treat[i].getPatient().getLastName());
    }
  
  
  
    @FXML
    private void btnLogout(ActionEvent event) throws Exception {
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(getClass().getResource("/views/FXMLLoginPage.FXML"));
      loader.load();
      Parent p = loader.getRoot();
      Stage stage = new Stage();
      stage.setScene(new Scene(p));
      stage.show();
      stage.centerOnScreen();
      // hides current page
      ((Node) (event.getSource())).getScene().getWindow().hide();
    }
  
  }
  </code></pre>
  
  <p>FXML for FXMLDoctorAssessmentPage</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.scene.shape.*?&gt;
  &lt;?import javafx.scene.text.*?&gt;
  &lt;?import javafx.scene.control.*?&gt;
  &lt;?import java.lang.*?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  &lt;?import javafx.scene.layout.AnchorPane?&gt;
  
  &lt;AnchorPane prefHeight="600.0" prefWidth="1000" stylesheets="@../styles/DoctorAssessmentPage1.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controllers.DoctorAssessmentPageController"&gt;
    &lt;children&gt;
      &lt;TabPane prefHeight="665.0" prefWidth="1385.0" tabClosingPolicy="UNAVAILABLE"&gt;
        &lt;tabs&gt;
          &lt;Tab text="Doctor Assessment"&gt;
            &lt;content&gt;
              &lt;AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="665.0" prefWidth="1385.0"&gt;
                &lt;children&gt;
                  &lt;Rectangle arcHeight="5.0" arcWidth="5.0" fill="#517da6" height="90.0" stroke="WHITE" strokeType="INSIDE" styleClass="rectangle-pane" width="1385.0" /&gt;
                  &lt;Rectangle arcHeight="5.0" arcWidth="5.0" fill="#72b2ee" height="53.0" layoutX="341.0" layoutY="494.0" stroke="WHITE" strokeType="INSIDE" styleClass="rectangle-pane2" width="193.0" /&gt;
                  &lt;Rectangle arcHeight="5.0" arcWidth="5.0" fill="#72b2ee" height="426.0" layoutX="43.0" layoutY="121.0" stroke="WHITE" strokeType="INSIDE" styleClass="rectangle-pane2" width="237.0" /&gt;
                  &lt;Label fx:id="nhsNumberLabel" layoutX="59.0" layoutY="226.0" prefHeight="20.0" prefWidth="158.0" styleClass="label-subTitle" /&gt;
                  &lt;Label fx:id="titleLabel" layoutX="57.0" layoutY="282.0" styleClass="label-subTitle" text="Label" /&gt;
                  &lt;Label fx:id="allergiesLabel" layoutX="56.0" layoutY="442.0" styleClass="label-subTitle" text="allergiesLabel" /&gt;
                  &lt;Label layoutX="58.0" layoutY="403.0" styleClass="label-info" text="Allergies:" /&gt;
                  &lt;Label fx:id="bloodTypeLabel" layoutX="57.0" layoutY="365.0" styleClass="label-subTitle" text="bloodTypeLabel" /&gt;
                  &lt;Label layoutX="57.0" layoutY="329.0" styleClass="label-info" text="Blood type:" /&gt;
                  &lt;Label layoutX="58.0" layoutY="251.0" prefHeight="25.0" prefWidth="66.0" styleClass="label-info" text="Name:" /&gt;
                  &lt;Label layoutX="58.0" layoutY="201.0" styleClass="label-info" text="NHS Number:" /&gt;
                  &lt;Label fx:id="lastNameLabel" layoutX="181.0" layoutY="282.0" styleClass="label-subTitle" text="Label" /&gt;
                  &lt;Label fx:id="firstNameLabel" layoutX="119.0" layoutY="282.0" styleClass="label-subTitle" text="Label" /&gt;
                  &lt;Button fx:id="btnExtend5mins" layoutX="1038.0" layoutY="389.0" mnemonicParsing="false" onAction="#btnExtend5minsClick" prefHeight="53.0" prefWidth="161.0" styleClass="button-extension" text="5+ minutes" /&gt;
                  &lt;Button layoutX="1038.0" layoutY="124.0" mnemonicParsing="false" prefHeight="53.0" prefWidth="161.0" text="Finalise Patient" /&gt;
                  &lt;TextArea layoutX="312.0" layoutY="122.0" prefHeight="321.0" prefWidth="270.0" promptText="Triage assessment" /&gt;
                  &lt;Label id="label-subTitle1" layoutX="57.0" layoutY="167.0" text="Patient" textFill="WHITE"&gt;
                    &lt;font&gt;
                      &lt;Font name="System Bold" size="15.0" /&gt;
                    &lt;/font&gt;
                  &lt;/Label&gt;
                  &lt;TextArea layoutX="621.0" layoutY="121.0" prefHeight="321.0" prefWidth="394.0" promptText="Doctor assessment" /&gt;
                  &lt;Label fx:id="timeSpentLabel" layoutX="438.0" layoutY="508.0" prefHeight="21.0" prefWidth="66.0" styleClass="label-subTitle" text="Label" /&gt;
                  &lt;Label layoutX="348.0" layoutY="508.0" prefHeight="25.0" prefWidth="89.0" styleClass="label-info" text="Time spent:" /&gt;
                  &lt;Button layoutX="1200.0" layoutY="25.0" mnemonicParsing="false" onAction="#btnLogout" text="Logout" /&gt;
                  &lt;Label fx:id="triageCategoryLabel" layoutX="57.0" layoutY="140.0" text="triageCategoryLabel" textFill="WHITE"&gt;
                    &lt;font&gt;
                      &lt;Font name="System Bold" size="15.0" /&gt;
                    &lt;/font&gt;
                  &lt;/Label&gt;
                  &lt;Label layoutX="348.0" layoutY="16.0" styleClass="label-title" text="Doctor Assessment &amp;amp; Treatment Room" /&gt;
                          &lt;Button layoutX="823.0" layoutY="504.0" mnemonicParsing="false" onAction="#buttonActionConfirmRoom" prefHeight="40.0" prefWidth="190.0" text="Confirm" /&gt;
                          &lt;ComboBox fx:id="comboBox" layoutX="619.0" layoutY="505.0" prefHeight="39.0" prefWidth="190.0" promptText="Select Room" visibleRowCount="5" /&gt;
                &lt;/children&gt;
              &lt;/AnchorPane&gt;
            &lt;/content&gt;
          &lt;/Tab&gt;
          &lt;Tab text="Queue"&gt;
            &lt;content&gt;
              &lt;AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"&gt;
                &lt;children&gt;
                  &lt;fx:include source="FXMLQueueTabPage.fxml" /&gt;
                &lt;/children&gt;
              &lt;/AnchorPane&gt;
            &lt;/content&gt;
          &lt;/Tab&gt;
          &lt;Tab closable="false" text="Treatment Rooms"&gt;
            &lt;content&gt;
              &lt;fx:include source="FXMLTreatmentRoomPage.fxml" /&gt;
            &lt;/content&gt;
          &lt;/Tab&gt;
        &lt;/tabs&gt;
      &lt;/TabPane&gt;
    &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>thanks,
  K</p>