Populating JTree from database

拟墨画扇 提交于 2019-12-04 08:40:56

Use DefaultMutableTreeNode to create your nodes

Make a map of IDs to nodes - as you get your nodes from the database, store them in the map with the id as their key.

Once you have all your nodes, go through them once more and match their parent ids up, retrieving them from the map.

Assuming your tree is structurally sound in the database, it will be sound here. Pick any node and follow the parent chain the the root.

With the root object, you can create your JTree. :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!