Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8764769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:06:59+00:00 2026-06-13T16:06:59+00:00

I am creating an editor application, and I am having a problem with my

  • 0

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

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:07:00+00:00Added an answer on June 13, 2026 at 4:07 pm

    In psuedocode, this is what you need to do…

    public TreeNode buildTree(){
        String[] names = new String[]; // fill this with the names of your plugins
    
        TreeNode tree;
    
        // for each plugin name...
        for (int i=0;i<names.length;i++){
            String currentName = names[i];
            String[] splitName = currentName.split(".");
    
            // loop over the split name and see if the nodes exist in the tree. If not, create them
            TreeNode parent = tree;
            for (int n=0;n<splitName.length;n++){
                if (parent.hasChild(splitName[n])){
                    // the parent node exists, so it doesn't need to be created. Store the node as 'parent' to use in the next loop run
                    parent = parent.getChild(splitName[n]);
                }
                else {
                    // the node doesn't exist, so create it. Then set it as 'parent' for use by the next loop run
                    TreeNode child = new TreeNode(splitName[n]);
                    parent.addChild(child);
                    parent = child;
                }
            }
    
    return tree;
    }
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an editor in asp.net MVC application using ckeditor. In textarea i
I am creating a editor kind of application where I want to compile and
I am creating a text editor using gtk+-2.0 gtksourceview-2.0. I want to be able
In the application I am creating, I am hooking an Editor up directly to
I'm using TinyMCE as the editor for creating an HTML form for people to
We have a Silverlight application using the RichTextBox as a rich text editor for
I'm creating my first web application - a really simplistic online text editor. What
I am creating an mp3tag editor and want it to get started via the
I'm creating a Win32 GUI application using Code::Blocks and MinGW. I am using this
I am creating LOB business application using ASP.NET MVC. In my views I find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.