Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTree Row Background Colour

 
S Dave
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to set the background colour for a particular selection in a JTree, the row numbers for which i know. i already have a renderer class of my own which extends DefaultTreeCellRenderer. this class alters the text of the JTree nodes.
How can i set the background colour for certain specific rows?
would appreciate all inputs.
thx
 
Matt Hansen
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the getTreeCellRendererComponent in your DefaultTreeCellRenderer you know the row. So you can then just setBackground if the row is one that you want colored.
 
S Dave
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well i have the row numbers in an array (the ones i want to change the background colour for).
how can i make these available to my renderer's getTreeCellComponent method?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!