Filling ChoiceBox with custom property in JavaFX
<p>How can I fill <code>ChoiceBox</code> with e.g. a <code>StringProperty</code> from my custom class?</p>

<p>I have simply design in SceneBuilder with a <code>ChoiceBox</code> and I have a <code>Person</code> class with my data.</p>

<pre><code>public class Person{
    private final StringProperty firstName;

    public Person(){
        this(null);
    }

    public Person(String fname){
        this.firstName = new SimpleStringProperty(fname);
    }

    public String getFirstName(){
        return this.firstName.get();
    }

    public void setFirstName(String fname){
        this.firstName.set(fname);
    }

    public StringProperty firstNameProperty(){
        return this.firstName;
    }
}
</code></pre>

<p>In main class I have:</p>

<pre><code>private ObservableList&lt;Person&gt; personList = FXCollections.observableArrayList();
this.personList.add(new Person("Human1"));

RootController controller = loader.getController();
        controller.setChoiceBox(this);

public ObservableList&lt;Person&gt; getPersonList(){
    return this.personList;
}
</code></pre>

<p>And in my controller: </p>

<pre><code>public class RootController {
    @FXML
    private ChoiceBox personBox;

    public RootController(){

    }

    @FXML 
    private void initialize(){

    }

    public void setChoiceBox(App app){

        personBox.setItems(app.getPersonList());
    }


}
</code></pre>

<p>But this code fill my ChoiceBox by function name(??) or something like that.
How can I fill it with the firstName property?</p>