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/Draaksward_89 Jan 22 '25
> I don't see any value in drilling through SelectionModel in a ChoiceBox
You may be right. This is basically a second week with me working on a javafx pet project, so I'm at the beginning of building the understanding of the whole API.
> Unless you are getting the subfolders from a file system call
Overall, the structure is retrieved from a file system, which is then persisted in a mongo db (haven't worked much with nosql, so decided to give it a try). This window is aimed to be a manager for folder entities.