i want to create a JTree resembling XML dom in java.. below is the XML form...
<html>
<head>
<title></title>
<style></style>
<body></body>
</head>
<head>
<title></title>
<style></style>
<body></body>
</head>
</html>
i want to create thi开发者_StackOverflow中文版s tree structure....
You can do it easily by parsing the XML and creating a DefaultMutableTreeNode for each XML element. Tree nodes have parents and children just like XML elements so the mapping is easy.
If you set the Element as the user object in DefaultMutableTreeNode you will probably want to provide a custom TreeCellRenderer.
There is a full example here: http://www.cafeconleche.org/books/xmljava/chapters/ch06s05.html
加载中,请稍侯......
精彩评论