title: javafx-2 ComboBox converter: method toString(T object) not called for null values
body: <p>In a javafx2 application, a ComboBox should present a list of items, in the example they are <code>String</code> s for simplicity.</p>
  
  <p>This list contains a <code>null</code> item, since i want the user to be allowed to make no choice.</p>
  
  <p>Since I was playing with the converter property of the ComboBox, I wondered if I could use it to provide a nice representation for the no-choice case, for example "[none]" instead of an empty line.<br/>
  But i've discovered that the toString(Object object) is never called for the null item.</p>
  
  <p>Here follows the shortest code that reproduces the case. Version information included.</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.scene.Scene;
  import javafx.scene.control.ComboBox;
  import javafx.stage.Stage;
  import javafx.util.StringConverter;
  
  public class T05 extends Application {
  @Override public void start(Stage primaryStage) throws Exception {
  
      System.out.println(System.getProperty("java.runtime.version"));
      System.out.println(System.getProperty("javafx.runtime.version"));
      System.out.println(System.getProperty("os.version"));
      System.out.println(System.getProperty("os.name"));        
  
      ComboBox c = new ComboBox();
      //c.setEditable(true);
      primaryStage.setScene(new Scene(c));
      primaryStage.show();
  
      c.getItems().add("first");
      c.getItems().add(null);
  
      c.setConverter(new StringConverter&lt;String&gt;(){
          @Override public String toString(String object) {
  
              System.out.print("converting object: ");
              if (object==null) {
                  System.out.println("null");
                  return "[none]";
              }
              System.out.println(object.toString());
              return object.toString();
          }
  
          @Override public String fromString(String string) {
              throw new RuntimeException("not required for non editable ComboBox");
          }
  
      });
  
  }
  
  }
  </code></pre>
  
  <p>And here it's the output, as you can see the true branch of the <code>if (object==null)</code> statement is never called. Is it a bug or a feature, and is it yet possible to customize null representation?</p>
  
  <pre><code> 1.6.0_29-b11
   2.2.3-b05
   6.1
   Windows 7
   converting object: first
   converting object: first
   converting object: first
  </code></pre>
  
  <p><strong>update</strong><br>
  Adding a (just uncomment it):</p>
  
  <pre><code>c.setEditable(true);
  </code></pre>
  
  <p>I get another behavior, that is, clicking on the null item in the combo selection box, I get the method toString called, but the result is not presented in the selection box. </p>