ChoiceBox
はどのようにして塗りつぶすことができますか?私のカスタムクラスのStringProperty
?JavaFXのカスタムプロパティでChoiceBoxを塗りつぶす
私はSceneBuilderで単にChoiceBox
というデザインをしましたが、データにはPerson
クラスがあります。
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;
}
}
:
private ObservableList<Person> personList = FXCollections.observableArrayList();
this.personList.add(new Person("Human1"));
RootController controller = loader.getController();
controller.setChoiceBox(this);
public ObservableList<Person> getPersonList(){
return this.personList;
}
そして、私のコントローラで:
public class RootController {
@FXML
private ChoiceBox personBox;
public RootController(){
}
@FXML
private void initialize(){
}
public void setChoiceBox(App app){
personBox.setItems(app.getPersonList());
}
}
しかし、このコードは、関数名(??)、またはそのような何かで私のChoiceBoxを埋めます。 firstNameプロパティでどのように記入できますか?あなたの問題のために
を?編集:ヒントのUpvote – SSchuette