title: How to populate ComboBox with Strings from a list of objects?
body: <p>I have a list of <code>Country</code> objects that have the instance variable <code>String countryName;</code>.
  I can't figure out how to populate the <code>ComboBox</code> with a list of Country objects.</p>
  <p>I tried doing it using a workaround by creating another list called</p>
  <p><code>ObservableList&lt;String&gt; listCountriesString = FXCollections.observableArrayList();</code></p>
  <p>and looping over it and adding every instance variable <code>countryName</code> to a new list:</p>
  <p><code>private ObservableList&lt;Country&gt; listCountries = FXCollections.observableArrayList();</code></p>
  <pre><code>for (Country country : listCountries) {
      listCountriesString.add(country.getCountryName());
  }
  </code></pre>
  <p>How can I use a ComboBox with my <code>Country</code> object, and displaying the country names only?</p>
  <pre><code>@FXML
  ComboBox&lt;Country&gt; comboBoxCountry;
  </code></pre>
  <pre><code>public class Country {
      private int countryId;
      private String countryName;
      private String createDate;
      private String lastUpdate;
  
      public Country(int countryId, String countryName, String createDate, String lastUpdate) {
          this.countryId = countryId;
          this.countryName = countryName;
          this.createDate = createDate;
          this.lastUpdate = lastUpdate;
      }
  
      ... getters and setters
  </code></pre>