开发者

Using ZK Tree component, how do I remove Treeitems from a Treechildren node

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> itera开发者_运维问答tor = myTreeItems.iterator();

while (iterator.hasNext()){
   myItem = (Treeitem)iterator.next();
   parent.removeChild(myItem);
}

Any ideas?


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.


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.


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()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜