show tooltip next to Jtree


Hello there,

I have created a JTree which gets populated from the database.Now i want to add a small description next to the nodes.How can i do this.for example.

-root (server)
    -child (linecard)
        -leaf (****)

zolfAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

suprapto45Commented:
zolfAuthor Commented:

thanks for your comments.instead of bring the mouse over the nodes to display the words,i want it be next to the nodes visible permanently without using mouse.
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

Mick BarryJava DeveloperCommented:
then use a custom cell renderer.
zolfAuthor Commented:

can you give me some example please
zolfAuthor Commented:

thanks objects for that site.that is exactly what i need.but when i when though the code,it is typed into the node like that

Person a1 = new Person("Jack (great-granddaddy)");

in my case it is like this

ResultSet tables = state.executeQuery("SELECT * FROM CITY");
            
        String tableName;                          
        DefaultMutableTreeNode tableNode,tableNode1,tableNode2;           // Stores a tree node for a table
        while(tables.next())                              // For each table
        {
          tableName = tables.getString("CITY_ENG_NAME");    // get the table name
          int cityID = tables.getInt("CITY_ID");
          tableNode = new DefaultMutableTreeNode(tableName);
          dbNode.add(tableNode);

Mick BarryJava DeveloperCommented:
well you can either set the text your require to be display in your tree node
or, create a new class that stores all the required details for the node, and use a custom cell renderer to format it as required
zolfAuthor Commented:

well you can either set the text your require to be display in your tree node

how can i achieve your first option.
Mick BarryJava DeveloperCommented:
tableNode = new DefaultMutableTreeNode(tableName + "("+description+")");

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.