Zha*_* Yi 5 java user-interface swing look-and-feel nimbus
我想要的是使不可编辑的文本区域的背景与其禁用的背景相同.
我知道颜色可以从UIManager
键中获得TextArea.disabled
:
DerivedColor(color=214,217,223 parent=control offsets=0.0,0.0,0.0,0 pColor=214,217,223
Run Code Online (Sandbox Code Playgroud)
我首先尝试过:
textArea.setBackground(UIManager.getColor("TextArea.disabled"));
Run Code Online (Sandbox Code Playgroud)
它什么都没改变,背景仍然是白色的.
然后我尝试了:
textArea.setBackground(new Color(UIManager.getColor("TextArea.disabled").getRGB()));
Run Code Online (Sandbox Code Playgroud)
背景确实发生了变化,但与看起来更亮的残疾背景并不完全相同.
处理这种衍生颜色的正确方法是什么?
我已经找到答案了。用于禁用背景的颜色不是UIManager.getColor("TextArea.disabled")
,而是在类中硬编码的TextAreaPainter
:
private Color color1 = decodeColor("nimbusBlueGrey", -0.015872955f, -0.07995863f, 0.15294117f, 0);
Run Code Online (Sandbox Code Playgroud)
使用这种颜色解决了我的问题。
归档时间: |
|
查看次数: |
1396 次 |
最近记录: |