Adding a Comment between Parent and Child in JTree

Posted on 2004-08-26
Last Modified: 2010-03-31

I would like to add a Comment between a Parent and a child in a JTree, Is this possible, if yes..pls help me with code snippet.

My reqt is like this.

o [] Root 1                                
|     THIS IS COMMENT    (String between parent & child)
       [] Child 1
       [] Child 2
 o-[] Root 2

Any suggestion..

Question by:vibhav
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 92

Expert Comment

ID: 11908270
thats just another child node isn't it.

Author Comment

ID: 11908284
Yes, but I do not want to display any icon to this node (like leaf or root (folder icon).

How to renderer it.
LVL 92

Accepted Solution

objects earned 250 total points
ID: 11908387
use a custom tree cell renderer and only display an icon on the nodes that need one.
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

LVL 18

Expert Comment

ID: 11909978
and how to remove Icons and show only text

Thanx to Objects for putting such nice examples together;)
LVL 16

Expert Comment

ID: 11910867
Why you need comment in this way?!?! In your custom tree cell renderer you can add tool tip for each one of the nodes. Just have a look at DefaultTreeCellRenderer and write your own in the same way...
LVL 92

Expert Comment

ID: 11918384

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question