[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 522
  • Last Modified:

Background Image for JTree

Hi,
Is it possible to add a background image for JTree?
If so, then how?
Thanks!
0
s_lavie
Asked:
s_lavie
  • 2
  • 2
1 Solution
 
objectsCommented:
Just override the paintComponent method and paint your image. You'll also need to ensure that your cell renderers are transparent.
0
 
s_lavieAuthor Commented:
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
 
objectsCommented:
Override JTree and add the following method:

public void paintComponent(Graphics g)
{
   g.drawImage(image, 0, 0, this);
   super.paintComponent(g);
}
0
 
s_lavieAuthor Commented:
>> 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
 
Venci75Commented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now