Problem with adding a node in jTree as it doesn't refresh

Status
Not open for further replies.

jack_daniels

Newbie level 1
Joined
Nov 2, 2007
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,291
Hi,
i´m trying to add a node in my jtree and make it show the added node but the tree doesn´t "refresh"
i´m posting the code here:

-----create tree-----
public JTree getJTreeContactos() {
if (jTreeContactos == null) {
DefaultMutableTreeNode grupo =
new DefaultMutableTreeNode("Amigos");
createNodes(grupo);//create the tree
jTreeContactos= new JTree(grupo);
jTreeContactos.setEditable(true);
jTreeContactos.getSelectionModel().setSelectionMod e
(TreeSelectionModel.SINGLE_TREE_SELECTION);
jTreeContactos.setBounds(new Rectangle(0, 0, 522, 268));
jTreeContactos.setShowsRootHandles(true);
}
return jTreeContactos;
}

-----add node-----
public void add_folha(String user_add)
{
nodd=new DefaultMutableTreeNode(user_add);
grupo.add(nodd);
jTreeContactos.scrollPathToVisible(new TreePath(nodd.getPath()));
}
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…