0

I have a list of categories (in the "model" class) that I want to show to user. The print is working so the data exists there but it not showed.

public class represController {
    public javafx.scene.control.ChoiceBox cb_categories=new ChoiceBox();
    List<String> eventCategories;
    model model=new model();

    public represController()
    {
        init_categories();
    }

    public void init_categories() {
        List<String> c=new ArrayList<>(model.getCategories());
        ObservableList<String> categs= FXCollections.observableArrayList(c);
        cb_categories.setItems(categs);
        System.out.println(cb_categories.getItems());
    }
  • 1
    You are missing the @Fxml annotation on your component if you are using FXML files. You also don't have to create the instance of it with `new ChoiceBox()` becaus it will be injected with the annotation. maybe you could follow a tutorial for the first examples. see also https://stackoverflow.com/questions/33881046/how-to-connect-fx-controller-with-main-app – pdem Jun 14 '19 at 07:47
  • 2
    Unrelated to your problem: please learn java naming conventions and stick to them. – kleopatra Jun 14 '19 at 08:10
  • 1
    I don't see any code that would add the `ChoiceBox` to a scene. (It's `public`, sure, but that doesn't mean you add the same `ChoiceBox` to a scene anywhere. We require a [mcve] for cases like these. Please [edit] the question to add more code. – fabian Jun 14 '19 at 10:54

0 Answers0