Solved

Background Image for JTree

Posted on 2002-04-28
5
473 Views
Last Modified: 2008-02-26
Hi,
Is it possible to add a background image for JTree?
If so, then how?
Thanks!
0
Comment
Question by:s_lavie
  • 2
  • 2
5 Comments
 
LVL 92

Expert Comment

by:objects
ID: 6975693
Just override the paintComponent method and paint your image. You'll also need to ensure that your cell renderers are transparent.
0
 
LVL 2

Author Comment

by:s_lavie
ID: 6990229
objects,
Can you please be more specific:
I have a file "background.gif" - I want it to be the background of a JTree.
Now step by step what do I have to do?
Thanks!
0
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 6992499
Override JTree and add the following method:

public void paintComponent(Graphics g)
{
   g.drawImage(image, 0, 0, this);
   super.paintComponent(g);
}
0
 
LVL 2

Author Comment

by:s_lavie
ID: 7004103
>> You'll also need to ensure that your cell
renderers are transparent.
How?
Sorry, if it's a silly question, but I've never used cell
renderers before.
Thanks again!
0
 
LVL 9

Expert Comment

by:Venci75
ID: 7992318
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Answered by: objects
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venci75
EE Cleanup Volunteer
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now