The Artima Developer Community
Sponsored Link

Java Answers Forum
Changing background row colour of JTree

3 replies on 1 page. Most recent reply: Sep 24, 2003 10:05 AM by David Postill

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Calum MacLean

Posts: 9
Nickname: calummacle
Registered: Feb, 2003

Changing background row colour of JTree Posted: Sep 24, 2003 5:19 AM
Reply to this message Reply
Advertisement
Hi

I'm wanting to be able to paint the background of each row of a JTree in a different colour.

Changing the renderer isn't sufficient, as I'd want to be able to paint parts of the row which aren't painted by the renderer - for example, at the LHS of the tree where the toggles and legs are.
So I'm talking about the whole row, covering the full width of the tree.

As a visual example, see the image at http://www.araxis.com/merge/overview2.html. In fact, it's precisely this sort of thing I want to do.

Looking at BasicTreeUI.paint(), it doesn't seem possible to "get in" at the right point. As it's the background, it should really be painted before anything else. However, there's no hook to let you do this sort of thing.

Does anyone have any ideas on how to accomplish this?

Thanks,

Calum


mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: Changing background row colour of JTree Posted: Sep 24, 2003 5:46 AM
Reply to this message Reply
http://www2.gol.com/users/tame/swing/examples/JTreeExamples2.html

This can be a help

Calum MacLean

Posts: 9
Nickname: calummacle
Registered: Feb, 2003

Re: Changing background row colour of JTree Posted: Sep 24, 2003 5:51 AM
Reply to this message Reply
Thanks for the link.

Unfortunately, I don't think any of the examples there deal with changing the background colour of the whole row.

Calum

David Postill

Posts: 1
Nickname: davidposti
Registered: Feb, 2003

Re: Changing background row colour of JTree Posted: Sep 24, 2003 10:05 AM
Reply to this message Reply
> Unfortunately, I don't think any of the examples there
> deal with changing the background colour of the whole
> row.
>
> Calum

You can do what you want with a JTreeTable. See:
http://java.sun.com/products/jfc/tsc/articles/treetable1/index.html

Flat View: This topic has 3 replies on 1 page
Topic: JSP & Struts - displaying a collection Previous Topic   Next Topic Topic: Please Help!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use