如何处理Nimbus外观中的派生颜色? [英] How to deal with derived color in Nimbus Look and Feel?

查看:94
本文介绍了如何处理Nimbus外观中的派生颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要使不可编辑的文本区域的背景与其禁用的背景相同.

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

我知道可以通过TextArea.disabled键从UIManager获得颜色:

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

我首先尝试过:

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

它什么都没有改变,背景仍然是白色的.

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

然后我尝试:

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?

推荐答案

我找到了答案.用于禁用背景的颜色不是UIManager.getColor("TextArea.disabled"),而是在TextAreaPainter类中硬编码的:

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.

这篇关于如何处理Nimbus外观中的派生颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆