title: JFXComboBox does not show default set value
body: <p>I am using a JFXComboBox to show user group a user can be allocated to. The roles are fetched from the DB.  Fetching of the <code>role</code>list is done by <code>getRoleNameList()</code>. I populate the JFXComboBox as below:</p>
  
  <p><strong>Populate userGroup JFXComboBox</strong></p>
  
  <pre><code>// Populate userGroup JFXComboBox
  ObservableList&lt;Role&gt; roles = rdc.getRoleNameList();
  roles.sort(Comparator.comparing(Role::getCode)); // Sort the list
  uGroupComboBox.getItems().setAll(roles);
  uGroupComboBox.setVisibleRowCount(5);
  </code></pre>
  
  <p><strong>JFXCombobox FXML:</strong></p>
  
  <pre><code>&lt;JFXComboBox id="userGroup" fx:id="uGroupComboBox" focusColor="#07595a" 
      layoutX="245.0" layoutY="256.0" prefHeight="30.0" prefWidth="148.0"
      promptText="Select User Group" styleClass="jfx-combo-box" 
      unFocusColor="#48aaad"&gt;
  </code></pre>
  
  <p><strong>The model below is for Roles:</strong></p>
  
  <pre><code>package records.models;
  import javafx.beans.property.SimpleStringProperty;
  import javafx.beans.property.StringProperty;
  import org.apache.commons.lang3.StringUtils;
  
  public class Role {
      private final StringProperty code;
      private final StringProperty name;
  
      public Role() {
          this.name = new SimpleStringProperty();
          this.code = new SimpleStringProperty();
      }
  
      public Role(String name) {
          String codename = StringUtils.capitalize(name.toLowerCase().trim());
          this.code = new SimpleStringProperty(codename);
  
          name = name.toLowerCase().trim();
          this.name = new SimpleStringProperty(name);
      }
  
      // name
      public String getName() {
          return name.get();
      }
  
      public void setName(String name) {
          if (name != null) {
              name = name.toLowerCase().trim();
          }
          this.name.set(name);
      }
  
      public StringProperty nameProperty() {
          return name;
      }
  
      // @return code
      public String getCode() {
          return code.get();
      }
  
      public void setCode(String code) {
          if (code != null) {
              code = StringUtils.capitalize(code.toLowerCase().trim());
          }
          this.code.set(code);
      }
  
      public StringProperty codeProperty() {
          return code;
      }
  
      public Role getRole(){
          return this;
      }
  
      @Override
      public String toString(){
          return this.code.get();
      }
  }
  </code></pre>
  
  <p>When I fetch from the DB the user group the user is assigned to, the data is not displayed:</p>
  
  <pre><code>String uRole = role.get("role") == null ? null : 
      role.get("role").toString();
  user.setRole(uRole);
  // Create the role that is fetched from DB
  Role uGroup = new Role(uRole);
  // uGroupComboBox.setValue(uGroup);
  uGroupComboBox.getSelectionModel().select(uGroup);
  </code></pre>
  
  <p>This does not work. As you can see, the field is not null. If it were, I would show the prompt text</p>
  
  <p><a href="https://i.stack.imgur.com/SltIh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SltIh.png" alt="This does not work. As you can see, the field is not null. If it were, I would show the prompt text"></a></p>
  
  <p>However, the JFXComboBox list is successfully populated:</p>
  
  <p><a href="https://i.stack.imgur.com/cHyyM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cHyyM.png" alt="enter image description here"></a></p>
  
  <p>If I do <code>System.out.println(uGroupComboBox.getValue());</code> it shows the correct value eg. <em>if the user group is <code>Nurse</code>, the statement returns <code>Nurse</code></em></p>
  
  <p>Why does the JFXComboBox not display the value?</p>