Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6550247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:11:35+00:00 2026-05-25T12:11:35+00:00

I have a custom ListCellRenderer and would like to use the default Nimbus selection

  • 0

I have a custom ListCellRenderer and would like to use the default Nimbus selection backround color. I can lookup the color with:

Color selectionBackground = UIManager.getColor("nimbusSelectionBackground");

and if I print it, it has the same values as on Nimbus default colors. But when I use it on a JPanel I get a different gray color, how can I use the color from UIManager?

When I do:

setBackground(Color.RED);

The JPanels backround is shown in red, but when I do:

setBackground(selectionBackground);

The “selectionBackground” color is not used, but a gray color.


Here is an example and screenshot:

enter image description here

The background should be:

enter image description here

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;

public class PanelColor {

    public static void main(String[] args) {

        // switch to Nimbus Look And Feel
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                try {
                    UIManager.setLookAndFeel(info.getClassName());
                } catch (Exception e) { e.printStackTrace(); }
                break;
            }
        }

        Color selectionBackground = UIManager.getColor("nimbusSelectionBackground");

        JPanel panel = new JPanel(new BorderLayout());
        panel.setPreferredSize(new Dimension(300,50));
        panel.add(new JLabel(selectionBackground.toString()), BorderLayout.NORTH);

        // is not showing the selectionBackground color
        panel.setBackground(selectionBackground);

        JFrame frame = new JFrame();
        frame.add(panel);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:11:36+00:00Added an answer on May 25, 2026 at 12:11 pm

    Nimbus apparently resists that its colors are used elsewhere. I stumbled across this a while ago too and back then my best solution was to create a new Color using the components (you can query) and use that. Of course, then you stick with that color even if the L&F is changed.

    I know that’s the whole point of a DerivedColor you get back from the UIManager. I haven’t found a better solution though.

    This goes similarly for other L&Fs and other things as well. E.g. the GTK L&F will happily give you icons you want to have but they won’t draw in your own controls. I guess part of all this is that Swing is (a) horribly complex and (b) no L&F out there actually adheres to the contracts, not even Nimbus, despite being the newest and coolest one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi i would like to create a custom calendar, this calendar will have custom
I'm making a custom ListCellRenderer. I know that you can have different dimensions for
I have custom validators and filters that I have created that I would like
I have custom coded several enterprise applications for mid to large organizations to use
Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators? For
I have custom exceptions in my django project that look like this: class CustomFooError(Exception):
I have custom slider that I use the following touch event to respond to:
I have custom errors turned on and when I go to www.mywebsite.com/video/default.aspx it shows
I have custom page and id of list item. How can i show sharepoint
I have custom SPlist with some fields that I'd like to bind to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.