javafx fxml ComboBox Error

前端 未结 2 1212
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-14 21:28

Im trying to add a String to a javafx comboBox but i keep getting the above error :/

no suitable method found for add(String)
method Collection.add(CAP#         


        
2条回答
  •  抹茶落季
    2021-01-14 22:12

    Simply declare the room_id field in your controller class as

    @FXML
    private ComboBox room_id;
    

    If you're using

    @FXML
    private ComboBox room_id;
    

    room_id.getItems() returns a ObservableList i.e. a ObservableList with unknown element type and String cannot be assigned to this type.

提交回复
热议问题