title: JavaFx 2 ChoiceBox with custom item
body: <p>I have a class such as:</p>
  
  <pre><code>public class myClass{
  
  int age;
  String name;
  
  public String toString(){
  return name;
  
  };
  }
  
  public static ObservableList&lt;myClass&gt; myClassList;
  </code></pre>
  
  <p>I wonder if is it possible to have </p>
  
  <pre><code>ChoiceBox&lt;myClass&gt; choiceChart = new ChoiceBox&lt;&gt;(myClassList);
  </code></pre>
  
  <p>Thanks</p>
  
  <p>PS I would like to have a similar situation as</p>
  
  <p><a href="https://stackoverflow.com/questions/13368572/rendering-a-pojo-with-javafx-2s-combo-box-without-overriding-the-tostring-met">Rendering a POJO with JavaFX 2</a></p>
  
  <p>but using a ChoiceBox</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>this is my situation: I have a tableView where in one of its columns I have to set a String from an object of myClass type, using the toString() method.</p>
  
  <p>I have tried to use these methods (where myClass --> CustomInternalWindow class  )</p>
  
  <pre><code>public static class Indicators{
        private final SimpleStringProperty tool_col;
        private final SimpleStringProperty chart_col;
        private final SimpleStringProperty pane_col;
        private final SimpleBooleanProperty on_col;
  
        private Indicators(String tl, CustomInternalWindow chrt, String pne, Boolean sel){
            this.tool_col = new SimpleStringProperty (tl);
            if (chrt == null) {
                this.chart_col = null;                  
            }
            else {
                this.chart_col = new SimpleStringProperty (chrt.toString());
            }
            this.pane_col = new SimpleStringProperty (pne);
            this.on_col = new SimpleBooleanProperty (sel);
  
        }
        public String getTool(){
            return tool_col.get();
        }
        public void setTool(String tl){
            tool_col.set(tl);
        }
  ...
  
  public SimpleBooleanProperty onProperty() {
            return on_col;
        }
        public SimpleStringProperty toolProperty(){
            return tool_col;
        }
        public SimpleStringProperty chartProperty(){
            return chart_col;
        }
        public SimpleStringProperty paneProperty(){
            return pane_col;
        }
  }  
  </code></pre>
  
  <p>and</p>
  
  <pre><code>  tablecolumnFrame.setCellFactory(new Callback&lt;TableColumn&lt;Indicators, CustomInternalWindow&gt;, TableCell&lt;Indicators, CustomInternalWindow&gt;&gt;(){
        @Override 
        public TableCell&lt;Indicators, CustomInternalWindow&gt; call(TableColumn&lt;Indicators, CustomInternalWindow&gt; param){
            TableCell&lt;Indicators, CustomInternalWindow&gt; cell = new TableCell&lt;Indicators, CustomInternalWindow&gt;(){
  
               @Override
               public void updateItem(CustomInternalWindow item, boolean empty) {
                      super.updateItem(item, empty);
                      if (item != null) {
                          ChoiceBox&lt;CustomInternalWindow&gt; choiceChart = new ChoiceBox&lt;&gt;(newprojectx.NewProjectXController.windowsPlotted);
                          choiceChart.setConverter(new CustomInternaWindowStringConverter());
                          choiceChart.getSelectionModel().select(item);
                          choiceChart.getSelectionModel().selectedItemProperty().addListener(new ChangeListener&lt;CustomInternalWindow&gt;() {                                        
                                      @Override
                                      public void changed(
                                      final ObservableValue&lt;? extends CustomInternalWindow&gt; ov, final CustomInternalWindow oldValue, final CustomInternalWindow newValue) {
                                          if (!isEditing()) {
                                              final TableView table = getTableView();
                                              if (table != null) {
                                                  table.edit(getTableRow().getIndex(), getTableColumn());
                                              }
                                          }
                                          commitEdit(newValue);
                                      }
                                  });
                          setGraphic(choiceChart);
                      }
                  }
              };             
              return cell;
        }
    });
  </code></pre>
  
  <p>but I am not able to display strings from windowsPlotted list</p>
  
  <p><strong>Update:</strong> I am still struggling with this issue, any help or suggestion really appreciated.</p>