Reputation:
Does anyone know how to remove Treeitems from a Treechildren node in ZK? I have tried using an iterator and removeChild but a ConcurrentModificationException!
List<Treeitem> myTreeItems = treechildren.getChildren();
Iterator<Treeitem> iterator = myTreeItems.iterator();
while (iterator.hasNext()){
myItem = (Treeitem)iterator.next();
parent.removeChild(myItem);
}
Any ideas?
Upvotes: 4
Views: 4135
Reputation: 517
Vbox hbC;
hbC.appendChild(hijo1);
hbC.appendChild(hijo2);
for(int i = 0;
i< hbC.getChildren().size(); i++){
hbC.removeChild(hbC.getChildren().get(i));
}
optional
try{
if(hbC.getChildren().size()>0){
for (Component c : hbC.getChildren()) {
hbC.removeChild(c);
}
}
1. List item
}catch()
Upvotes: -1
Reputation: 168
As what I saw in your case you want to remove all components which are all attached on a treechildren
.
I think the fastest way is:
treechildren.getChildren().clear();
just operate the result like a java.util.List
.
Upvotes: 0
Reputation: 429
That is not the correct way to remove the items, you need to do something like this.
while (parent.getItemCount() > 0) {
parent.removeChild(parent.getFirstChild());
}
This will provide the functionality that you require!
More details on using the Tree component are available here.
Upvotes: 3