Why are JLabels not transparent in my JList?

Posted on 2011-10-10
Last Modified: 2012-05-12
Any idea why the JLabels arent transparent?

My process:
1.Create a JPanel using GridBagLayout Manager. Add a few JLabels.
2. Add the JPanel to an object array.
3. Pass object array into JList (setListData() method)
4. Call the setCellRenderer(new JListRenderer()) method

And it displays on screen with gray bg. Where am i going wrong?

Any thoughts or suggestions are appreciated.

 Screenshot of non transparent JLabels.
Question by:Gregg
    LVL 47

    Accepted Solution


    check this:

    you probably need to cal setOpaque(false)
    or set Background color on those elemesnt which you add to your component
    LVL 10

    Author Closing Comment

    Yeah! I had it backwards, i had setOpaque(true).  Thanks for your help!

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
    For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
    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 …
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    734 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

    25 Experts available now in Live!

    Get 1:1 Help Now