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

  • SEARCH
  • Home
  • 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 4335576
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:41:19+00:00 2026-05-21T10:41:19+00:00

I have the following problem: I want to have a JTeeTable-like table component except

  • 0

I have the following problem:

I want to have a JTeeTable-like table component except that the roots (classes below) and the nodes of the tree are not of the same type.

For instance, suppose that I have the following classes:

public final class Entry {

    private int id;
    private String title;
    private String notes;

    private List<SubEntry> subEntryList; /** @see SubEntry*/
}


public final class SubEntry{
    private int id;
    private String title;
    private String notes;

}

Although these two class look similar and may motivate for a case for inheritance, they are NOT related that way. Think of it as a car with a list of car parts OR movie with a list of actors.

For two weeks now I have been trying to think of a way to present the above visually. I thought of using the JTreeTable component but all the examples I’ve come are cross show usage when the subentries (nodes??) are of the same type as the entries (leaf??).

My Idea So Far:
Seeing that if I use a table, the columns will share the same names, I thought I should use a table and another table as a TableCellRenderer and then support show/hide on double-click of the parent row.

I am not sure how to move forward though…

So, if you have any ideas how I should go about this, please share your ideas.

UPDATE

//I finally managed to sort out the tree table model.
//Below is the snippet of what I have done. 

        private List<Entry> root; 

        public EntryTreeTableModel(List<Entry> root) { 
              this.root = root;
        } 

    public int getChildCount(Object parent) { 

      if (parent instanceof List){ 
             return ((ArrayList<Entry>) parent).size(); 
      }else if (parent instanceof Entry){ 
            return ((Entry)parent).getSubEntries().size(); 
      } 
     return 0; 
   }

   public Object getChild(Object parent, int index) {
        if (parent instanceof List){
            return ((ArrayList<Entry>) parent).get(index);
        }else if (parent instanceof Entry){
            return ((Entry)parent).getSubEntries().get(index);
        }else if (parent instanceof Entry){
            return ((SubEntry)parent); // Hmmm, this feels wrong. Check later.
        }
            return "...";  // Just to indicate that something went wrong
    }

Other methods of follow the same approach

Many thanks to all those who shared
their ideas. Another thank to
Trashgod…

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

    The class org.netbeans.swing.outline.Outline appears to be a good candidate, as suggested by this example. In particular, Outline uses javax.swing.tree.TreeModel, which “accepts any kind of object as a tree node.” Comparing your model to the example’s, Entry would correspond to a directory, and SubEntry would correspond to a list of files contained therein. See Creating a Data Model for a related example.

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

Sidebar

Related Questions

I have the following problem that I want to solve in awk. I have
I have the following problem. I want to check that the item clicked on
I have the following problem. I have an array of bytes that I want
Hi I have the following problem. Given a Tree I want to be able
I have following problem: I want to count data in one table, count data
I have the following problem: I want that the user make a download when
I am using GWT/JAVA for development. I have following problem: I want to remove
I have the following problem: Within a stylesheet document I want to create an
Hi I have the following problem, I want to laod a website with php.
What kind of strategy do I have for the following problem. I want to

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.