java - Change the icon of Jtree Root Node -
below code have created jtree root node "data generation..
rootnode = new defaultmutabletreenode("data generation"); treemodel =new defaulttreemodel(rootnode); tree = new jtree(treemodel); tree.seteditable(true);
i have changed icon images leaf node
childnode=new defaultmutabletreenode(existingtagnames.get(len).tostring()); defaulttreecellrenderer renderer = (defaulttreecellrenderer) tree.getcellrenderer(); imageicon imageicon = new imageicon(generate_explorer.class.getresource("/org/qmon/generate/images/leaf node.png")); renderer.setleaficon(imageicon); tree.setcellrenderer(renderer);
i dont know how root node.. searched in internet unable find it.
thanks in advance.
if use these 2 methods on renderer, should set icon on non-leaf nodes.
setclosedicon(icon newicon) setopenicon(icon icon)
Comments
Post a Comment