title: Combo-box select item in JavaFX 2
body: <p>I have one [JavaFX] <code>ComboBox</code> that is populated with countries.</p>
  <p>My object:</p>
  <pre><code>public static class CountryObj {
      private  String TCountryDescr;
      private  String TCountryCode;        
  
      private CountryObj(String CountryDescr,String CountryCode) {
          this.TCountryDescr = CountryDescr;         
          this.TCountryCode = CountryCode;             
      }  
  
      public String getTCountryCode() {
          return TCountryCode;
      }
  
      public void setTCountryCode(String fComp) {
          TCountryCode= fComp;
      }         
  
      public String getTCountryDescr() {
          return TCountryDescr;
      }
  
      public void setCountryDescr(String fdescr) {
          TCountryDescr = fdescr;
      }                 
  
      @Override
      public String toString() {
          return TCountryDescr;
      }
  }    
  </code></pre>
  <p>Then I have my <code>ObservableList</code>:</p>
  <pre><code>private final ObservableList&lt;CountryObj&gt; CountrycomboList =
      FXCollections.observableArrayList(
                   new CountryObj(&quot;United States&quot;, &quot;US&quot;),
                   new CountryObj(&quot;United Kingdom&quot;, &quot;UK&quot;),
                   new CountryObj(&quot;France&quot;, &quot;FR&quot;),
                   new CountryObj(&quot;Germany&quot;, &quot;DE&quot;));    
  </code></pre>
  <p>Then my <code>ComboBox</code> which displays the name of the country and the code of the country is for my own use:</p>
  <pre><code>private ComboBox&lt;CountryObj&gt; cCountry1 = new ComboBox&lt;&gt;();
  
  cbCountry1.setItems(CountrycomboList);
  
  cbCountry1.getSelectionModel().selectedItemProperty().addListener(new                  ChangeListener&lt;CountryObj&gt;() {
  
          @Override
          public void changed(ObservableValue&lt;? extends CountryObj&gt; arg0, CountryObj arg1, CountryObj arg2) {
              if (arg2 != null) {
                  System.out.println(&quot;Selected Country: &quot; + arg2.getTCountryCode());
              }
          }
      });
  </code></pre>
  <p>How can I auto-select a country, for example Germany, if I only have the code of the country, which is &quot;DE&quot;?</p>