Skip to content
Advertisement

JavaFX search in listview

I want to search in listview and my code is working but not well enough. The problem is when i write few characters in the search text field not only the result appears, but the rest of the items also appear…

The code:

JavaScript

Photos: Original list: Original list

Sorted list: Sorted list

ListCell implementation:

JavaScript

Advertisement

Answer

Your problem is not in your filter logic.

I think you have a bad ListCell implementation that does not clear its text when it is supposed to display nothing.

Update

Yeah, your cell renderer does not clear the cell when the item is null. Try something like this:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement