title: combobox jump to typed char
body: <p>I stumbled on (in my eyes) a silly problem. However I don't find a solution for this (maybe because of not using the right search keywords, or by making it too difficult when it can be easy..)
  Scenario:</p>
  
  <p>I have a combobox with 500 customers. I have to select a single costumer.</p>
  
  <p>In Swing, when the list was down and you started typing, it automatically jumps to the typed letter. E.g.:</p>
  
  <p>Items:</p>
  
  <ul>
  <li>Adam</li>
  <li>Dirk</li>
  <li>Freddy</li>
  <li>...</li>
  <li>Roger</li>
  <li>Steven</li>
  <li>Z person</li>
  </ul>
  
  <p>When the combobox list is open, I just type 'R' and, in swing, it jumped to the first customer starting with 'R'. In javafx 2 it seems it does not have that behaviour... Is there some option that I have to enable or should I do something like using an <strong>editable</strong> combobox instead and make a <code>filter()</code> method that is fired on every keypress?</p>
  
  <p><strong>Edit</strong>: sollution based on Bhupendra's answer:</p>
  
  <pre><code>public class FilterComboBox&lt;T&gt; extends ComboBox&lt;T&gt; {
  private final FilterComboBox&lt;T&gt; fcbo = this;
  
  //private FilterComboBox fcbo = this;
  private ObservableList&lt;T&gt; items;
  private ObservableList&lt;T&gt; filter;
  private String s;
  private Object selection;
  
  private class KeyHandler implements EventHandler&lt; KeyEvent&gt; {
  
      private SingleSelectionModel&lt;T&gt; sm;
  
      public KeyHandler() {
          sm = getSelectionModel();
          s = "";
      }
  
      @Override
      public void handle(KeyEvent event) {
          filter.clear();
          // handle non alphanumeric keys like backspace, delete etc
          if (event.getCode() == KeyCode.BACK_SPACE &amp;&amp; s.length() &gt; 0) {
              s = s.substring(0, s.length() - 1);
          } else {
              s += event.getText();
          }
  
          if (s.length() == 0) {
              fcbo.setItems(items);
              sm.selectFirst();
              return;
          }
          //System.out.println(s);
          if (event.getCode().isLetterKey()) {
              for (T item : items) {
                  if (item.toString().toUpperCase().startsWith(s.toUpperCase())) {
  
                      filter.add(item);
                      //System.out.println(item);
  
                      fcbo.setItems(filter);
  
                      //sm.clearSelection();
                      //sm.select(item);
  
                  }
              }
              sm.select(0);
          }
  
      }
  }
  
  public FilterComboBox(final ObservableList&lt;T&gt; items) {
      super(items);
      this.items = items;
      this.filter = FXCollections.observableArrayList();
  
      setOnKeyReleased(new KeyHandler());
  
      this.focusedProperty().addListener(new ChangeListener() {
          @Override
          public void changed(ObservableValue observable, Object oldValue, Object newValue) {
              if (newValue == false) {
                  s = "";
                  fcbo.setItems(items);
                  fcbo.getSelectionModel().select((T)selection);
              }
  
          }
      });
  
      this.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
          @Override
          public void changed(ObservableValue observable, Object oldValue, Object newValue) {
              if (newValue != null) {
                  selection = (Object) newValue;
              }
  
          }
      });
  }
  </code></pre>
  
  <p>}</p>