Selecting multiple items from combobox

后端 未结 3 1278
梦毁少年i
梦毁少年i 2020-12-20 00:32

Pls i want to know how to change the selectionmodel of javafxml combobox so that it can allow multiple seletion. Any contribution will be appreciated thanks.

3条回答
  •  粉色の甜心
    2020-12-20 01:10

    I need something similar and this solved my problem.

    @FXML
    public MenuButton menuButton;  
    ......  
    CheckBox cb0 = new CheckBox("x");  
    CustomMenuItem item0 = new CustomMenuItem(cb0);  
    CheckBox cb1 = new CheckBox("y");  
    CustomMenuItem item1 = new CustomMenuItem(cb1);  
    item0.setHideOnClick(false);  
    item1.setHideOnClick(false);  
    menuButton.getItems().setAll(item0,item1);
    

提交回复
热议问题