jack_daniels
Newbie level 1
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()));
}
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()));
}