TreeModel

A

Arun

Hi,

My program starts by loading an xml file to a JTree. It does so by
building up a rootNode, adding this to a TreeModel to the JTree.
Like buildTree = new JTree(treeModel).

How do i go about loading a complete new xml file, which creates a
complete new rootNode etc, which will in turn change the contents of
the JTree.

I tried adding this new rootNode to the treemodel, but this doenst
update the JTree.
 
M

Michael Rauscher

Arun said:
Hi,

My program starts by loading an xml file to a JTree. It does so by
building up a rootNode, adding this to a TreeModel to the JTree.
Like buildTree = new JTree(treeModel).

How do i go about loading a complete new xml file, which creates a
complete new rootNode etc, which will in turn change the contents of
the JTree.

I tried adding this new rootNode to the treemodel, but this doenst
update the JTree.

Your model would need a method like setRoot(...). This method will have
to inform the JTree about the change you made. This is done by notifying
the listeners via TreeModelListener#treeStructureChanged. The
corresponding TreeModelEvent must hold a reference to the new root node,
of course.

Bye
Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Extra Row in JTree 6
DOM extension of JTree 2
Refreshing JTree 6
"Thread View" of a tree. 3
Java DOM: add an attribute to a node 2
Why does JTree scrolling too slow? 1
JTree? 10
JTree, setSelectionPath 0

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,273
Latest member
DamonShoem

Latest Threads

Top