在我的 Java 应用程序中,我必须自定义绘制一个控件,为此我需要使用与 JButton
相同的字体颜色。 (启用和禁用)我不想对它们进行硬编码,因为用户可以在运行时更改 Substance 皮肤。
我知道ColorSchemes
,但我不确定在获得当前皮肤的配色方案后如何继续。 Substance 文档也说了一些关于创建您自己的配色方案的内容,但我只是想不出检索特定颜色的方法。
最佳答案
好吧,最后我自己弄明白了:
重要的一步是找出正确的配色方案。因为在 Substance 中每个根 Pane 都可以有自己的皮肤,所以最好使用 getCurrentSkin
helper。
SubstanceColorScheme s = SubstanceLookAndFeel
.getCurrentSkin(myComponent)
.getEnabledColorScheme(
SubstanceLookAndFeel.getDecorationType(myComponent)
);
其他可能性是 getDisabledColorScheme
、getActiveColorScheme
和 getBackgroundColorScheme
。
然后您可以使用 s.getForegroundColor
或 SubstanceColorUtilities
中的各种辅助方法。
关于java - 如何使用 Substance LaF 获取按钮的文本颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2871548/