?
Solved

JTree question

Posted on 2001-08-26
3
Medium Priority
?
704 Views
Last Modified: 2008-02-26
I have JTree which a fill with nodes at the first time.
After that a call removeAllChildren() method for some node and I am adding a brand new set of nodes as childrens for this node. Why the JTree doesn't changes? (There are only interrupted lines to previous childs which are still visible)!
0
Comment
Question by:msterjev
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 92

Expert Comment

by:objects
ID: 6427145
Sounds like your making calls on the tree node (as opposed to the model).
The tree node do not support firing TreeModelEvent's.
If you change your nodes you must also ensure that the matching events are fired by your tree model.
0
 
LVL 3

Author Comment

by:msterjev
ID: 6427539
The events are minor problem. Give me example how to dinamically change structure of one node( remove all its childrens and add new ones)!
0
 
LVL 92

Accepted Solution

by:
objects earned 80 total points
ID: 6427563
> The events are minor problem

No, events are the problem.
The Jtree updates itself according to events recieved from its tree model.

> Give me example how to ...

If you're using a DefaultTreeModel then just call treemodel.reload(node) after you've finished modifying the nodes children.



0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month13 days, 12 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question