title: JavaFX combobox didn't show correct value from objects
body: <p>I am using JavaFX, Hibernate, Spring in my project. </p>
  
  <p>And i need to fill the combobox with my object values.
  In my combobox i need to show only title value from my model. </p>
  
  <p>My model class:</p>
  
  <pre><code>public class Sector extends Identifier {
      private String title;
  
      private List&lt;Stage&gt; stageList;
  
      public List&lt;Stage&gt; getStageList() {
          return stageList;
      }
  
      public void setStageList(List&lt;Stage&gt; stageList) {
          this.stageList = stageList;
      }
  
      public String getTitle() {
          return title;
      }
  
      public void setTitle(String title) {
          this.title = title;
      }
  
      @Override
      public String toString() {
          return "Sector{" +
                  "id='" + getId() + '\'' +
                  "title='" + title + '\'' +
                  ", stageList=" + stageList +
                  '}';
      }
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>public class Stage extends Identifier {
      private String name;
  
      private Station firstStation;
  
      private Station secondStation;
  
      private List&lt;CommunicationDistance&gt; communicationDistanceList;
  
      public Stage() {
      }
  
      public Stage(String name, Station firstStation, Station secondStation) {
          this.name = name;
          this.firstStation = firstStation;
          this.secondStation = secondStation;
      }
  
      public List&lt;CommunicationDistance&gt; getCommunicationDistanceList() {
          return communicationDistanceList;
      }
  
      public void setCommunicationDistanceList(List&lt;CommunicationDistance&gt; communicationDistanceList) {
          this.communicationDistanceList = communicationDistanceList;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public Station getFirstStation() {
          return firstStation;
      }
  
      public void setFirstStation(Station firstStation) {
          this.firstStation = firstStation;
      }
  
      public Station getSecondStation() {
          return secondStation;
      }
  
      public void setSecondStation(Station secondStation) {
          this.secondStation = secondStation;
      }
  
      @Override
      public String toString() {
          return "Stage{" +
                  "id='" + getId() + '\'' +
                  "name='" + name + '\'' +
                  ", firstStation=" + firstStation +
                  ", secondStation=" + secondStation +
                  ", communicationDistanceList=" + communicationDistanceList +
                  '}';
      }
  </code></pre>
  
  <p>In my controller there is some method-listener for combobox  to make some other manipulations with this data:
  (about cell factory i read from <a href="http://javafx-and-me.blogspot.com/2013/10/custom-combobox.html" rel="nofollow noreferrer">this question</a>  and also <a href="https://stackoverflow.com/questions/10699655/combo-box-key-value-pair-in-javafx-2">from here</a>)</p>
  
  <pre><code>   @FXML
          public void currentSectorSelected(ActionEvent actionEvent) {
              ObservableList&lt;Stage&gt; observableList = FXCollections.observableArrayList(((Sector) sector.getSelectionModel().getSelectedItem()).getStageList());
              stage.setItems(observableList);
              stage.getSelectionModel().selectFirst();
  
              stage.setCellFactory(new Callback&lt;ListView&lt;Stage&gt;, ListCell&lt;Stage&gt;&gt;() {
                  @Override
                  public ListCell&lt;Stage&gt; call(ListView&lt;Stage&gt; param) {
  
                      return new ListCell&lt;Stage&gt;(){
                          @Override
                          public void updateItem(Stage item, boolean empty){
                              super.updateItem(item, empty);
                              if(!empty) {
                                  setText(item.getName());
                                  setGraphic(null);
                              } else {
                                  setText(null);
                              }
                          }
                      };
                  }
              });
          }
  </code></pre>
  
  <p>All is working, but in my comboboxes values shown like these:
  <a href="https://i.stack.imgur.com/IylFj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IylFj.jpg" alt="enter image description here"></a></p>
  
  <p>This are my correct objects but, still i can't understand how to format my combobox to show only title field from my Sector and other objects?
  Can you show some valid/correct example to format my combobox output? </p>
  
  <p><strong>Edit 1:</strong>
  In my init method i am simply added the list of my objects to combobox. I am not sure that this is correct way, but if i want to validate this data after combobox value is chosen - i must to set a full object in combobox:</p>
  
  <pre><code>  @FXML
          public ComboBox sectorComboBox;
  
      @Override
          public void initialize(URL location, ResourceBundle resources) {
              sectorComboBox.setItems(FXCollections.observableArrayList(sectorService.listAll()));
          }
  </code></pre>