Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > [JTree] Adding a leaf to a node

Thread Tools

[JTree] Adding a leaf to a node

Alexandre Jaquet
Posts: n/a
Hi I'm working with JTree and I need to know
how to add to a specifique node a leaf.

My tree will represent a contact list and all the nodes are groups.
And I would like to add to a particular groups an user.

I began to try something like that :

public void addUsers (String userName , String group, String statut) {

for (int i = 0; i < rootNode.getChildCount();i++) {
if (rootNode.getChildAt(i).toString() == group) {
DefaultMutableTreeNode leaf = new DefaultMutableTreeNode(userName +
" " +

// And here I would like to add to the node at [i] a new leaf


Thanks for your help.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Leaf Node in SiteMapPath Uriah Piddle ASP .Net 3 09-17-2006 08:17 PM
xsl variable $node/text() but $node can non-node-set help! Tjerk Wolterink XML 2 08-24-2006 03:28 AM
TreeView - disabling hyperlink on the leaf node mazdotnet ASP .Net 1 08-01-2006 03:24 PM
How to set the node indent property between the parent node and the leaf node ASP .Net 0 02-13-2006 07:11 PM
[JTree] click on a node or a leaf Alexandre Jaquet Java 2 11-11-2003 02:15 PM