Change the color of one or more nodes in Jtree dynamically

大憨熊 提交于 2021-01-28 14:12:38

问题


I have created Jtree with Root node and 4Subnodes.
My problem is like this:

  • I need to change the foreground and background color of a particular node dynamically.

How can i do it?
Help me with some piece of code.

Thank you all in advance...


回答1:


How can i do it?

I'm sure that JTree tutorial contains valuable info about DefaultTreeCellRenderer,

Help me with some piece of code.

tons of examples here or here or here




回答2:


One easy way I found was to include HTML markup in the node text. The renderer (Windows 7, Java7.45) respects font color changes. Low-rent but gets the job done!



来源:https://stackoverflow.com/questions/8652862/change-the-color-of-one-or-more-nodes-in-jtree-dynamically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!