[JTree] Adding a leaf to a node

  • Thread starter Alexandre Jaquet
  • Start date
A

Alexandre Jaquet

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 +
" " +
statut);

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

}
}
}

Thanks for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top