Solved

Background Image for JTree

Posted on 2002-04-28
5
492 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
type mismatch (Object[] to double[] 4 41
Android development question 2 80
SequenceInputStream example 3 22
jmeter usage 4 37
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

733 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