java - Completely expand all node of a Jtree (including children) -
java - Completely expand all node of a Jtree (including children) -
i found details on net problem solution not seem work .
i want able expand nodes ( including leaf nodes ) of jtree . code have far .
tree = new jtree(treemodel); tree.setshowsroothandles(true); tree.seteditable(true); tree.addtreeselectionlistener(treeselectionlistener); tree.addmouselistener(mouselistener); tree.setcellrenderer(new filecellrenderer()); (int = 0; < tree.getrowcount(); i++) { tree.expandrow(i); }
this not expand leaf nodes . image want image b .
use recursive call, in next sample:
private void expandallnodes(jtree tree, int startingindex, int rowcount){ for(int i=startingindex;i<rowcount;++i){ tree.expandrow(i); } if(tree.getrowcount()!=rowcount){ expandallnodes(rowcount, tree.getrowcount()); } }
java swing jtree
Comments
Post a Comment