r/JavaFX • u/Draaksward_89 • Jan 21 '25
Help How to clear an ItemView?
I'm working on a UI part, which is basically a list of directories and its contents

Whenever you select the ChoiceBox, there is a list of subfolders.
I have a ChangeListener hooked up to ChoiceBox, which basically calls
listView.getItems().clear();
listView.getItems().addAll(...);
listView.refresh();If I'm switching content of listView from 10 elements to 3 (from `Interrogator` to `Pariah Nexus`) I'm getting leftovers.
And the leftovers are not clickable. Just a graphical glitch.
How to address this?
1
Upvotes
View all comments
Show parent comment
1
u/hamsterrage1 Jan 22 '25
The point is to avoid long or potentially blocking operations on the FXAT. When you make a call to any external service, including MongoDB or the file system, your code essentially executes a "wait", which is, by definition, blocking.
Maybe it works 99% of the time, but when the database request fails and it takes 30 seconds or more for the request to time out, then your GUI hangs.