Solved

Background Image for JTree

Posted on 2002-04-28
5
482 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 96
even odd program using while loop 3 40
Java exception bubble up 2 18
hibernate example for saving data 19 38
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.

776 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