Solved

JTree question

Posted on 2001-08-26
3
696 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
  • 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 20 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
java  and programming certification ? 4 86
thymeleaf natural templating vs JSP 2 68
eclipse java  build path 6 45
JavaScript/Java - Changing an image background color 4 56
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now