I am creating an editor application, and I am having a problem with my menus. In the object menu, I want to display several objects types using a JTree
. These object types are dynamically registered by plugins and follow this style:
trigger.button
trigger.lever
out.door.fallgate
trigger.plate
out.door.door
...
This list of names is unsorted and I want to build a TreeNode
structure for a JTree
like this:
- trigger
- button
- lever
- plate
- out
- door
- fallgate
- door
- door
Additionally, if the user selects a leaf node, I need to recreate the object name (e.g. trigger.button) from the TreePath
. Could someone please advise how this can be done.
In psuedocode, this is what you need to do...
This is only psuedocode - you'll need to do the work of implementing the TreeNode methods properly, etc. Give it a try yourself - if you have any more problems, create a question and show us that you've attempted to do it yourself, then we will be more willing to help you solve the minor problems.