Solved

Is there a way to make a jlist transparent?

Posted on 2012-03-11
6
604 Views
Last Modified: 2012-06-27
Hi,

Is there a way to make a jlist transparent?

Thanks
0
Comment
Question by:taborrg
  • 3
  • 3
6 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 37706602
Look at this answer to similar quewstion here which worked:



http://www.dreamincode.net/forums/topic/183398-how-to-make-jlist-transparent/


Re: How to make JList transparent?

Posted 27 July 2010 - 10:09 AM
I *THINK* you need to the cell renderer to be transparent too. This may involve making your own custom cell renderer. The API has an example of how to do that. You can probably copy their example and modify it to suit your needs (setting it to non-opaque, of course).
API link:

http://docs.oracle.com/javase/6/docs/api/javax/swing/JList.html
0
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 37706613
I guess this is a better link which gives full code of JList drwan
on top of the image using ListCellRenderer:
http://www.javarichclient.com/display-a-jlist-with-a-background-image/
0
 
LVL 1

Author Comment

by:taborrg
ID: 37706617
I saw the first link earlier, but couldn't make sense of it.

The second link lots like I might be able to follow it.  Will probably take a day.

Thanks
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 47

Expert Comment

by:for_yan
ID: 37706634
about the first link.

This link
http://docs.oracle.com/javase/6/docs/api/javax/swing/JList.html
goves an example of using ListCellRenderer with the list.
The main method of ListCelllRenderer
 public Component getListCellRendererComponent(..)
needs to return a subclass of JComponent - they show how to use
subclass of JLabel to return from this method by creating MyListCellRenderer extending JLabel. Then making JList transparent will be the same as making JLabel's, returned for each cell, transparent, which you should be able to achieve by using setOpaque(false)
in the end where this method returns JLabel, like in this place
 setOpaque(true); // change this to false
         return this;


It looks like the asker in that case tried and was happy with that.
It seems to me it should work either.

Anyway try the second one if that one is closer to what you like to achieve
0
 
LVL 1

Author Comment

by:taborrg
ID: 37706639
I appreciate the explanation - I'll take another look at it.
0
 
LVL 1

Author Closing Comment

by:taborrg
ID: 37708308
Thanks for the help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping1 challenge 7 73
Starting to learn JAVA, 7 59
custom annotations 9 31
table example 4 22
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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

911 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

23 Experts available now in Live!

Get 1:1 Help Now