title: How to display different value with ComboBoxTableCell?
body: <p>I try to use <code>ComboxBoxTableCell</code> without success.<br>
  The content of the cell display the right value for the attribute of an object. But when the combobox is displayed, all items are displayed with the <code>toString</code> object method and not the attribute.<br>
  I tryed to override <code>updateItem</code> of <code>ComboBoxTableCell</code> or to provide a <code>StringConverter</code> but nothing works.  </p>
  
  <p>Do you have some ideas to custom comboxbox list display in a table cell ?  </p>
  
  <p>I put a short example below to see quickly the problem. Execute the app and click in the cell, you will see the combobox with <code>toString</code> value of the object.  </p>
  
  <pre class="lang-js prettyprint-override"><code>package javafx2;  
  
  import javafx.application.Application;
  import javafx.beans.property.adapter.JavaBeanObjectPropertyBuilder;
  import javafx.beans.value.ObservableValue;
  import javafx.collections.FXCollections;
  import javafx.collections.ObservableList;
  import javafx.scene.Scene;
  import javafx.scene.control.TableCell;
  import javafx.scene.control.TableColumn;
  import javafx.scene.control.TableColumn.CellDataFeatures;
  import javafx.scene.control.TableView;
  import javafx.scene.control.cell.ComboBoxTableCell;
  import javafx.stage.Stage;
  import javafx.util.Callback;
  import javafx.util.StringConverter;
  
  public class ComboBoxTableCellTest extends Application {
  
      public class Product {
          private String name;
          public Product(String name) {
              this.name = name;
          }
          public String getName() { return name; }
          public void setName(String name) { this.name = name; }
      }
  
      public class Command {
          private Integer quantite;
          private Product product;
          public Command(Product product, Integer quantite) {
              this.product = product;
              this.quantite = quantite;
          }
          public Integer getQuantite() { return quantite; }
          public void setQuantite(Integer quantite) { this.quantite = quantite; }
          public Product getProduct() { return product; }
          public void setProduct(Product product) { this.product = product; }
      }
  
      public static void main(String[] args) {
          launch(args);
      }
  
      @Override
      public void start(Stage stage) throws Exception {
          Product p1 = new Product("Product 1");
          Product p2 = new Product("Product 2");
          final ObservableList&lt;Product&gt; products  = FXCollections.observableArrayList(p1, p2);
          ObservableList&lt;Command&gt; commands  = FXCollections.observableArrayList(new Command(p1, 20)); 
  
          TableView&lt;Command&gt; tv = new TableView&lt;Command&gt;();
          tv.setItems(commands);
  
          TableColumn&lt;Command, Product&gt; tc = new TableColumn&lt;Command, Product&gt;("Product");
          tc.setMinWidth(140);
          tc.setCellValueFactory(new Callback&lt;TableColumn.CellDataFeatures&lt;Command,Product&gt;, ObservableValue&lt;Product&gt;&gt;() {
  
              @Override
              public ObservableValue&lt;Product&gt; call(CellDataFeatures&lt;Command, Product&gt; cdf) {
                  try {
                      JavaBeanObjectPropertyBuilder&lt;Product&gt; jbdpb = JavaBeanObjectPropertyBuilder.create();
                      jbdpb.bean(cdf.getValue());
                      jbdpb.name("product");
                      return (ObservableValue) jbdpb.build();
                  } catch (NoSuchMethodException e) {
                      System.err.println(e.getMessage());
                  }
                  return null;
              }
          });
          final StringConverter&lt;Product&gt; converter = new StringConverter&lt;ComboBoxTableCellTest.Product&gt;() {
  
              @Override
              public String toString(Product p) {
                  return p.getName();
              }
  
              @Override
          public Product fromString(String s) {
                  // TODO Auto-generated method stub
                  return null;
              }
          };
  
          tc.setCellFactory(new Callback&lt;TableColumn&lt;Command,Product&gt;, TableCell&lt;Command,Product&gt;&gt;() {
  
              @Override
              public TableCell&lt;Command, Product&gt; call(TableColumn&lt;Command, Product&gt; tc) {
                  return new ComboBoxTableCell&lt;Command, Product&gt;(converter, products) {
                      @Override
                      public void updateItem(Product product, boolean empty) {
                          super.updateItem(product, empty);
                          if (product != null) {
                              setText(product.getName());
                          }
                      }
                  };
              }
          });
  
          tv.getColumns().add(tc);
          tv.setEditable(true);
  
          Scene scene = new Scene(tv, 140, 200);
          stage.setScene(scene);
          stage.show();
      }
  }
  </code></pre>