javafx - CheckComboBox choices are empty -
hi learning javafx , want create dropdown multiple select. think need use checkcombobox. implement did no show elements. here`s code:
in fxml : <checkcombobox fx:id="keywordbox" layoutx="233.0" layouty="240.0" prefheight="25.0" prefwidth="131.0" />
in controller:
@override public void initialize(url location, resourcebundle resources) { final observablelist<string> strings = fxcollections.observablearraylist(); (int = 0; <= 4; i++) { strings.add("item " + i); } keywordbox = new checkcombobox<string>(strings); keywordbox.getcheckmodel().getcheckeditems().addlistener(new listchangelistener<string>() { public void onchanged(listchangelistener.change<? extends string> c) { system.out.println(keywordbox.getcheckmodel().getcheckeditems()); } }); }
and dropdown empty. idea?
you creating new checkcombobox instead of using 1 fxml.
remove line:
keywordbox = new checkcombobox<string>(strings);
and add items model of existing keywordbox.
Comments
Post a Comment