[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

show tooltip next to Jtree

Posted on 2006-04-23
10
Medium Priority
?
342 Views
Last Modified: 2006-11-18

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
Comment
Question by:zolf
  • 5
  • 4
10 Comments
 
LVL 16

Expert Comment

by:suprapto45
ID: 16522390
0
 

Author Comment

by:zolf
ID: 16522458

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
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!

 
LVL 92

Expert Comment

by:objects
ID: 16522527
then use a custom cell renderer.
0
 

Author Comment

by:zolf
ID: 16522559

can you give me some example please
0
 

Author Comment

by:zolf
ID: 16522617

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
 
LVL 92

Expert Comment

by:objects
ID: 16522820
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
 

Author Comment

by:zolf
ID: 16522924

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

how can i achieve your first option.
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 16522941
tableNode = new DefaultMutableTreeNode(tableName + "("+description+")");
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month20 days, 12 hours left to enroll

864 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