aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes find org.jdom.Element in JTree Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "find org.jdom.Element in JTree" Watch "find org.jdom.Element in JTree" New topic
Author

find org.jdom.Element in JTree

Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
Hi guys
In my app I have org.jdom.Element that comes from xml SAX parser,
And swing JTree ,
(the SAX parser is parsing the same XML of the JTree)

Is there any convenient way I can locate the Element in the JTree
Besides trying to recursively iterate the JTree model ?

If it was DefaultMutableTreeNode I could call currentNode.getPath()
And then get the TreeNode[] or TreePath �

Thank you very much
Sharon
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
jdom seems stopped development

jdom-1.0.tar.gz 09-Sep-2004

It is probably the time to consider switch API...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

Just had a quick look at the documentation. I would say, you don't have to recursively iterate the tree because JDOM has a method (getDescendants) that does that for you. And you could pass it a Filter -- most likely an ElementFilter -- that would just choose the Element(s) you were looking for.
Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
Thanks for the response ,

can I get JTree Element directly by providing TreePath object to the JTREE ?
say the tree is :


and i want to get the JTree element at : ["Cars" , "Volvo" , "s80" , "16v 2500"]
?
Thank you
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61657
    
  67

"sharon pl",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
>>FYI
>>Sorry, that member's private message mailbox is currently full. Please >>try sending your private message another time.
>>� http://www.javaranch.com

Hi Bear ,
please empty your inbox
Sharon
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: find org.jdom.Element in JTree