• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTree - Change structure problem

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I'm doing an app that uses a JTree that I want to dinamically change.

I want to move up and down two kind of nodes (all my nodes extends DefaultMutableTreeNode).

If I remove any node, the tree responses fine, using the 'removeNodeFromParent()' as I could see into previous message, but I don't find the way to move the nodes.

There are an up and a down button, that move up/down with the inmediately next/previous node.

I try all the methods of the DefaultTreeModel and little bit combinations of these...

By example:

projectTreeModel().nodeStructureChanged(node1);
projectTreeModel().nodeStructureChanged(node2);

or

Anybody has a suggestion to do this?

Very thanks in advance.

Saludos!
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Javier Camara:
I'm doing an app that uses a JTree that I want to dinamically change.

I want to move up and down two kind of nodes (all my nodes extends DefaultMutableTreeNode).

If I remove any node, the tree responses fine, using the 'removeNodeFromParent()' as I could see into previous message, but I don't find the way to move the nodes.

There are an up and a down button, that move up/down with the inmediately next/previous node.

I try all the methods of the DefaultTreeModel and little bit combinations of these...

By example:

projectTreeModel().nodeStructureChanged(node1);
projectTreeModel().nodeStructureChanged(node2);

or

Anybody has a suggestion to do this?



You should be ok so long as you only use the methods provided by DefaultTreeModel [insertNodeInto() and removeNodeFromParent()] and don't call the nodes' methods directly [so no node1.insert()].

If you're already doing that then I guess we need more details.
[ March 07, 2008: Message edited by: Brian Cole ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic