Is there a way to make a jlist transparent?

Posted on 2012-03-11
Last Modified: 2012-06-27

Is there a way to make a jlist transparent?

Question by:taborrg
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
  • 3
  • 3
LVL 47

Expert Comment

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

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:
LVL 47

Accepted Solution

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:

Author Comment

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.

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 47

Expert Comment

ID: 37706634
about the first link.

This link
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

Author Comment

ID: 37706639
I appreciate the explanation - I'll take another look at it.

Author Closing Comment

ID: 37708308
Thanks for the help.

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
Way to decrease size of apk file 9 108
How to determine if a string is a valid SHA value 7 43
Glassfish admin console not working 1 56
Tagging and Merging on Branch 1 41
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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 …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

749 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