This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

generate Jtree

 
Moniphal Say
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have one file .dtd, I want to generate Jtree (show the content of the file inform of Jtree).
Anyone could tell me how to do it please!

Moniphal
 
Seetesh Hindlekar
Ranch Hand
Posts: 244
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Jtree is a Swing component. Anyways use the following code snippet.

DefaultMutableTreeNode root;
root = new DefaultMutableTreeNode("Foods");
JTree tree = new JTree(root); //create tree
addNodes(<elments of the xml file after parsing> ;

private void addNodes(String b, String n1)
{ DefaultMutableTreeNode base = new DefaultMutableTreeNode(b);
root.add(base);
base.add(new DefaultMutableTreeNode(n1));
}

Rgds,

Seetesh
 
Moniphal Say
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Seetesh,

Thanks so much for your help !
I will back to ask questions again if I have any problems !

Regards,
Moniphal
 
Tad Dicks
Ranch Hand
Posts: 264
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was just wondering the same thing. A DTD isn't xml though, Are there any good apis for parsing DTDs (is this part xalan xerces or some other common tool)?

Is there an elegant way to extend a J-tree to show the relationships between parent and nested tags ? optional, + one or more, * 0 or many. etc. The Jtree can nicely show order and what is allowed but seems to fall a little short in showing the relationships I mentioned.

-Tad
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic