TableView items are not removed but do not respond

一笑奈何 提交于 2019-12-11 19:17:46

问题



Firstly, I am working on Windows 7, Netbeans 8, JDK 8.
I have a TableView containing POJO objects (not using properties).
I am trying to implement "search while typing" but something strange happens.
In this image you can see that ALL the students are being displayed:


In the next picture after the search is done you can see the problem.
First 4 students are the actual search results and are clickable active entries in the TableView.
All the others entries are visible but not responding, but instead they should have been removed completely.



How it works (coding part):
1. When users types 'f' a function is called.
2. In the function I create new list that will contain the search results:
ObservableList<Student> subentries = FXCollections.observableArrayList();
3. Then I add all items matching the criteria of the search in subentries list
4. I call:
5. studentsTable.setItems(subentries);
Erroneous result is shown in picture 2.
HACKS I tried:
1. randomButton.fire();
2.
columnsOfTheTable.get(0).setVisible(false);
columnsOfTheTable.get(0).setVisible(true);

The above don't work.
Any help would be appreciated.
Thanks


回答1:


This is a bit of a guess, but if you are using custom cells (or rows) in your table, make sure their updateItem(...) methods properly handle empty cells:

@Override
public void updateItem(SomeType item, boolean empty) {
    super.updateItem(item, boolean);
    if (empty) {
        setText(null);
        setGraphic(null);
    } else {
        // configure cell...
    }
}


来源:https://stackoverflow.com/questions/23180428/tableview-items-are-not-removed-but-do-not-respond

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!