JTree

[email protected] Tue, 1 Mar 2005 10:44:32 -0800
Newsgroups gmane.comp.embedded.carlsbad-cubes
Message-ID <BB7491BA8B7C53409CBD58F7F79D8C3B181BAA@DED01EXVS01.wcbradley.local>
Hello All,

Has anyone been successful creating a tree with it's nodes from an XML
descriptor file?  I've been playing around with this today and can not
get around the fact that DefaultMutableTreeNode, TreeNode, etc. do not
extend from either Component or Container.  The addChild method of the
Parser object requires that the object you are adding be a Component or
inherited from Component.  I would like to have an xml document that is
something like the following:

<tree>
	<node>text1</node>
	<node>text2</node>
</tree>

I have messed a little with trying to use the initclass attribute of the
tree tag but no luck so far.  Any suggestion would be appreciated.  Does
anyone know if this functionality is scheduled for the next release?  If
not I am going to try and adjust the addChild method myself in the
following manor:

1. Ensure the appropriate packages are imported for
DefaultMutableTreeNode
2. Change the component parameter of the addChild method to an Object
type
3. Create an if else block that is true for (component instanceof
DefaultMutableTreeNode)
4. Populate this block with the appropriate code to generate a node
structure for the parent (Container) tree.
5. Make addChild throw an exception on no match of any if or if else
block.
6. Adjust the calling method, getSwing, to handle the exception.

There may be more steps required once I dive deeper.  Of course, if
someelse has a better solution or is working on this please let me know.

Thanks,
Andrew

_______________________________________________
Forum mailing list
[email protected]
http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com