title: Combobox refresh value and listview when object content change
body: <p>I would like to update my combobox when the content of the object used to display text in combo changes.</p>
  
  <p>Here is a sample:</p>
  
  <pre><code>package com.javafx.example.combobox;
  
  import javafx.application.Application;
  import javafx.beans.property.SimpleStringProperty;
  import javafx.beans.property.StringProperty;
  import javafx.collections.FXCollections;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.control.ComboBox;
  import javafx.scene.control.TextField;
  import javafx.scene.layout.HBox;
  import javafx.scene.layout.Priority;
  import javafx.stage.Stage;
  import javafx.util.StringConverter;
  
  public class ComboboxSample extends Application {
  
  
      class Sequence {
          public StringProperty name = new SimpleStringProperty();
  
          public Sequence(String name) {
              super();
              this.name.set(name);
          }
  
          @Override
          public String toString() {
              return "null";
          }
      }
  
      @Override
      public void start(Stage stage) throws Exception {
          stage.setTitle("ComboBoxSample");
  
          ComboBox&lt;Sequence&gt; combo = new ComboBox&lt;&gt;();
          combo.setItems(FXCollections.observableArrayList(
                  new Sequence("Toto"),
                  new Sequence("Titi")));
          combo.getSelectionModel().selectFirst();
          combo.setConverter(new StringConverter&lt;ComboboxSample.Sequence&gt;() {
              @Override
              public String toString(Sequence sequence) {
                  return sequence.name.get();
              }
  
              @Override
              public Sequence fromString(String string) {
                  System.out.println("call fromString");
                  return null;
              }
          });
  
          TextField text = new TextField();
          Button renameButton = new Button("Rename");
  
          renameButton.setOnAction(evt -&gt; combo.getValue().name.set(text.getText()));
  
          HBox root = new HBox(combo, text, renameButton);
          HBox.setHgrow(text, Priority.ALWAYS);
  
          stage.setScene(new Scene(root));
          stage.show();
  
      }
  
      public static void main(String... args) {
          launch(args);
      }
  }
  </code></pre>
  
  <p>The combobox contains objects with a property name. If i rename this property, the display do not change or sometimes it changes but not all the time. It is the standard behavior as the combobox update when the object changes, and not when its content changes.</p>
  
  <p>How can i do to force the combobox to refresh its value and the listview on change?</p>
  
  <p>Thanks</p>
  
  <p>EDIT1:</p>
  
  <p>Using a callback in an observaleList seems to be a solution.
  package com.javafx.example.combobox;</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.beans.Observable;
  import javafx.beans.property.SimpleStringProperty;
  import javafx.beans.property.StringProperty;
  import javafx.collections.FXCollections;
  import javafx.collections.ObservableList;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.control.ComboBox;
  import javafx.scene.control.TextField;
  import javafx.scene.layout.HBox;
  import javafx.scene.layout.Priority;
  import javafx.stage.Stage;
  import javafx.util.Callback;
  import javafx.util.StringConverter;
  
  public class ComboboxSample extends Application {
  
      ObservableList&lt;Sequence&gt; sequences;
  
  
      class Sequence {
          public StringProperty name = new SimpleStringProperty();
  
          public Sequence(String name) {
              super();
              this.name.set(name);
          }
  
          @Override
          public String toString() {
              return "null";
          }
      }
  
      @Override
      public void start(Stage stage) throws Exception {
          stage.setTitle("ComboBoxSample");
  
          Callback&lt;Sequence, Observable[]&gt; extractor = new Callback&lt;Sequence, Observable[]&gt;() {
              @Override
              public Observable[] call(Sequence s) {
                  return new Observable[] {s.name};
              }
          };
          sequences = FXCollections.observableArrayList(extractor);
          sequences.addAll(
                  new Sequence("Toto"),
                  new Sequence("Titi"));
  
          ComboBox&lt;Sequence&gt; combo = new ComboBox&lt;&gt;();
          combo.setItems(sequences);
          combo.getSelectionModel().selectFirst();
          combo.setConverter(new StringConverter&lt;ComboboxSample.Sequence&gt;() {
              @Override
              public String toString(Sequence sequence) {
                  return sequence.name.get();
              }
  
              @Override
              public Sequence fromString(String string) {
                  System.out.println("call fromString");
                  return null;
              }
          });
          combo.valueProperty().addListener((obs, oldValue, newValue) -&gt; System.out.println("Change from " + oldValue.name.get() + " to " + newValue.name.get())); 
  
          TextField text = new TextField();
          Button renameButton = new Button("Rename");
  
          renameButton.setOnAction(evt -&gt; {
              combo.getValue().name.set(text.getText());
          });
  
          HBox root = new HBox(combo, text, renameButton);
          HBox.setHgrow(text, Priority.ALWAYS);
  
          stage.setScene(new Scene(root));
          stage.show();
  
      }
  
      public static void main(String... args) {
          launch(args);
      }
  }
  </code></pre>