Disable JTree Selected Node’s Selection Color

If you want to change a JTree selected node’s rendering to just, say a bold and italic text, you can do so by calling the setBackgroundSelectionColor() and setBorderSelectionColor() of the DefaultTreeCellRenderer and passing null as its parameter.

You can use this same code in this post and placing those methods within the code that checks if the component is selected or not. Compile and run your program again and see that when you select a JTree’s node, there is only a bold and italic text without any background selection color.

Related Posts Plugin for WordPress, Blogger...

Leave a Reply

Your email address will not be published. Required fields are marked *