• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 359
  • Last Modified:

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 (****)

0
zolf
Asked:
zolf
  • 5
  • 4
1 Solution
 
suprapto45Commented:
0
 
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.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
objectsCommented:
then use a custom cell renderer.
0
 
zolfAuthor Commented:

can you give me some example please
0
 
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);

0
 
objectsCommented:
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
0
 
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.
0
 
objectsCommented:
tableNode = new DefaultMutableTreeNode(tableName + "("+description+")");
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now