File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Problem with label Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem with label" Watch "Problem with label" New topic

Problem with label

visu Nekk
Ranch Hand

Joined: Sep 06, 2005
Posts: 122
I have a peculiar problem.I have a root node A.To this root node,I am adding a child node B and to this node,I am adding another node C.My problem is when i am adding another child node to A,the labels to the nodes are sometimes missing.It's of this form.When i add another node to A,I am going for a full repaint of the tree.

A(root node)
| |_C
| |_D
Can anyone help me out?
Thanx in advance.
Sloan Bowman
Ranch Hand

Joined: Jan 21, 2003
Posts: 107
So are you asking how to repaint the tree to make sure the newly added nodes show up properly? If so you should be able to run the validate() and repaint() and be in good shape. Am I missing something?
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

If this tree is a JTree, and your tree model is a DefaultTreeModel, then have a look at the API documentation for methods whose names start with "fire". You call the appropriate method from that list whenever you make a change to a node, or add a node, or delete a node. Calling validate() or repaint() is a crude solution that might not work well for large trees.
visu Nekk
Ranch Hand

Joined: Sep 06, 2005
Posts: 122
Thanx Paul, I am using validate().If it's not a good solution for large trees,then please suggest me another method.

I agree. Here's the link:
subject: Problem with label
It's not a secret anymore!