如何处理Nimbus外观中的派生颜色? [英] 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.
我知道可以通过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屋!