Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2005

Tip: Looking for answers? Try searching our database.

JTree root node is demoted, but ...

Thread view: 
hiwa - 13 Jan 2005 10:40 GMT
I have made a JTree:

JTree tree = new JTree(orignalRootNode);

Then, I have demoted the root:

newRootNode.add(originalRootNode);

Now, real root node is newRootNode.

tree = new JTree(newRootNode);

But, aren't there more moderate ways for tree updating
than this brute-force?

It seems any method of tree model and tree node can't do
that.
Thomas Fritsch - 13 Jan 2005 12:54 GMT
> I have made a JTree:
>
[quoted text clipped - 13 lines]
> It seems any method of tree model and tree node can't do
> that.

If you have a DefaultTreeModel (or a subclass of it), you can simply
call its method
  public void setRoot(TreeNode root);
for example like this:
  ((DefaultTreeModel) tree.getModel()).setRoot(newRootNode);

If you don't have a DefaultTreeModel, you could override its method
  public Object getRoot();
of interface TreeModel and implement a setRoot method of your own.

Signature

"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.