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 4025518
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:51:24+00:00 2026-05-20T10:51:24+00:00

I have a non-UI use for a so-called k-ary tree in my Java application

  • 0

I have a non-UI use for a so-called “k-ary” tree in my Java application and was wondering if the javax.swing.tree package was the right tool for the job, even though its packaged with Swing.

I have a class of, say, Widget objects that need to be organized as a tree. Each node of this Widget tree can have 0+ children, and thus it is not necessarily symmetric.

I need a generic Tree/Node structure that will allow me to use Widgets or any other object. Specifically, I need a traverse that does (at the very least) post-order traversals.

If I’m not looking in the right package, can someone point me in the right direction?

  • 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-05-20T10:51:24+00:00Added an answer on May 20, 2026 at 10:51 am

    While you might be able to finagle that class to do what you want, I get the sense that it’s much more tightly coupled to JTree than you’d like. The general Google consensus is that building your own is a quick exercise that pays off well – I was able to find two different implementations in the top few results.

    • http://vivin.net/2010/01/30/generic-n-ary-tree-in-java/
    • http://sujitpal.blogspot.com/2006/05/java-data-structure-generic-tree.html

    If you have some burning need to roll your own, the general idea is to define a Node class with a List<Node> of children. Then all you have to do is provide your own methods for things like insert, delete, etc. Recursive postorder traversal is as simple as doing a regular binary postorder, except instead of left-right-root you simply walk the list of children doing postorder on each, then iterate the root last.

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

Sidebar

Related Questions

I use a non-default Windows colour scheme on most of my machines, and have
We have a SQL server database. To manipulate the data non-programmatically, I can use
We have a (non-web app) Spring application that throws a NoSuchBeanDefinitionException when running tests
I'm making a non-garbage-collected MacFUSE Cocoa application, inside of which I want to use
I've been trying to deal with some delimited text files that have non standard
I have a non-.Net executable file that is included in my .net assembly as
I have a non-visual component which manages other visual controls. I need to have
Suppose I have a non-recurring event that needs to be raised X seconds from
If I have a non-template (i.e. normal) class and wish to have a template
Is it possible to create/have a non-modal .net OpenFileDialog I have a UI element

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.