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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:35:22+00:00 2026-05-27T16:35:22+00:00

I have this Jtree, and I have to insert into it tables in my

  • 0

I have this Jtree, and I have to insert into it “tables” in my tbltables table. (What I mean by that is I have a table in my MSQL database called tbltables, and in it there’s a list of tables).

So those tables can have tables in them as well. So now the problem: I don’t know how to tell it that the one table should be in the other one. The only thing I can think of, is when I add the tables to my Jtree (I can do that, but then not save how they look into my db), I can then save the selected index, or added node’s destination. like [“Groceries”,”fruit”] and then when I call it from my database I can add it like that.

So then I will need to convert the path to a string and vice versa. Am I doing this wrong? Is there better way to do this?

Note: I’m not working with physical files and folders, I’m working with “imaginary ones” in my database of which I have their destination.

  • 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-27T16:35:22+00:00Added an answer on May 27, 2026 at 4:35 pm

    I would say your table should have primary key (let’s name it table_id) and a foreign key parent_table_id referencing the primary key. The parent id could be null (e.g. for root).

    You can define class MyTableNode with id, parent id and name fields. Build your TreeModel based on the MyTableNode hierarchy. DefaultMutableTreeNode can keep any user object.

    Then your can define own renderer for the JTree to show name text of the user objects (MyTableNodes ) or try to override toString() method of the object which is used to show value in default renderer.

    Your way (storing paths as string) could also work. REpresent your node’s TreePath as “root/first child/…/leaf”. SO each table (row of the JTree) will have own path.
    Then restoring the tree node means parsing the path to String[] and navigating from the tree root finding appropriate child with the next name from the array.

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

Sidebar

Related Questions

I have a JTree that implements multi selection logic. This works great when I
I have a database table named tree1, which has a table names student_details.This table
I have a custom JTree implementation that implemts convertValueToText . This implementation depends on
I am writing this application in Java, where I have a JTree on the
I have a JTree and the Nodes are a abstract class (Item) that extends
I have a simple Jython GUI that displays an XML file in a JTree.
Hi guys i have xmlstring this string comes from database. I need to populate
I want to have a JTree in my swing application that does not have
I create a Jtree that all of its nodes have User object, I fill
Let's say, I have this code of a jTree JTree jTree = new JTree()

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.