Link to home
Start Free TrialLog in
Avatar of Zolf
ZolfFlag for United Arab Emirates

asked on

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

Avatar of suprapto45
suprapto45
Flag of Singapore image

Avatar of Zolf

ASKER


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.
then use a custom cell renderer.
Avatar of Zolf

ASKER


can you give me some example please
Avatar of Zolf

ASKER


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);

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
Avatar of Zolf

ASKER


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

how can i achieve your first option.
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial