javafx listview and treeview controls are not repainted correctly

ε祈祈猫儿з 提交于 2019-11-26 11:56:34

Your cell factory's updateItem(...) needs to handle the case where the cell is empty. This will be exactly the scenario when an item is removed (or becomes empty because a node in the TreeView was collapsed) and the cell that previously showed an item is reused as an empty cell:

public ListCell<T> call(final ListView<T> param) {
    ListCell<T> cell = new ListCell<T>(){
        @Override
        protected void updateItem(final T persistentObject, final boolean empty) {
            super.updateItem(persistentObject, empty);
            if (empty) {
                setText(null);
                setGraphic(null);
            } else {
                // ... rest of your code.
            }
       }
    }
    return cell ;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!