javafx - make ListView not selectable via mouse

前端 未结 7 2178
执念已碎
执念已碎 2020-12-20 16:33

Is there an option in JavaFX to deactivate the possibility to select the items in a ListView via mouse?

I\'d like to just display a ListView

7条回答
  •  遥遥无期
    2020-12-20 17:03

    Mordechai's approach works really great.
    I tried to comment with another addition for JFoenix JFXListView but the code formatting wasn't good so I created this answer:

    If you are using JFoenix and the JFXListView you have also the behaviour that you can still see the JFXRippler on cell selection.
    To prevent this or change the rippler override the cell factory:

    //Replace T with your specific type.
    listView.setCellFactory(param -> new JFXListCell() {
    
        @Override
        protected void updateItem(T item, boolean empty) {
            super.updateItem(item, empty);
            cellRippler = new JFXRippler(); //create empty rippler
        }
    });
    

提交回复
热议问题