• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with label

 
visu Nekk
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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)
|_B
| |_C
| |_D
|
|_B
|_C
|_D
Can anyone help me out?
Thanx in advance.
 
Sloan Bowman
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20978
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Paul, I am using validate().If it's not a good solution for large trees,then please suggest me another method.

Regards,
Visu.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic