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 this 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
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.