Solved

Is there a way to make a jlist transparent?

Posted on 2012-03-11
6
631 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
couple of eclipse 5 45
Tomcat: Unable to run tomcat service. 2 23
How to execute a Python program and gather return output in Java 2 40
Problem to Alipay 10 42
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This video teaches viewers about errors in exception handling.

808 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