Search code examples
javaswinguser-interfacelook-and-feelnimbus

How to deal with derived color in Nimbus Look and Feel?


What I want is to make the background of a uneditable text area the same as its disabled background.

I know that the color is available from the UIManager with the key TextArea.disabled:

DerivedColor(color=214,217,223 parent=control offsets=0.0,0.0,0.0,0 pColor=214,217,223

I firstly tried:

textArea.setBackground(UIManager.getColor("TextArea.disabled"));

It changed nothing at all and the background was still white.

Then I tried:

textArea.setBackground(new Color(UIManager.getColor("TextArea.disabled").getRGB()));

The background did change but was not exactly the same as the disabled background which looks brighter.

What is the correct way to deal with this derived color?


Solution

  • I've found the answer. The color used for disabled background is not UIManager.getColor("TextArea.disabled"), but hard-coded in class TextAreaPainter:

    private Color color1 = decodeColor("nimbusBlueGrey", -0.015872955f, -0.07995863f, 0.15294117f, 0);
    

    Using this color solves my issue.