I am developing a Swing application in which I need to show the tooltip for JTree nodes. The nodes represent certain tasks and run in an independent threads sequentially. I need to change the tooltip as per the current status of the tasks.
I overrode getToolTipText(MouseEvent e) method in a class that extends JTree. This shows a tooltip too, but the look & feel of the tooltip of other components in my application is different than what is shown for Jtree nodes.
Please see the attached image of a desired look & feel of the tooltip. This tooltip is set on JTabbedPane.
And here is the screenshot of the tooltip that is being displayed on Jtree:
I tried html tags but that doesn't work. I also tried setting the look & feel of Jtree node tooltip by using following code, but this doesn't work either. The color codes I used below are same as the ones shown in desired tooltip above:
UIManager.put("ToolTip.background", new ColorUIResource(255, 247, 200)); // The color is #fff7c8.
Border border = BorderFactory.createLineBorder(new Color(76,79,83)); // The color is #4c4f53.
UIManager.put("ToolTip.border", border);
Can someone please tell me how can I set my JTree tooltip as shown in a desired image above?
You can override the
createToolTip
method fromJTree
in your tree class:Example: