【问题标题】:How can I get the text color of a button using the Substance LaF?如何使用 Substance LaF 获取按钮的文本颜色?
【发布时间】:2010-05-20 06:48:14
【问题描述】:

在我的 Java 应用程序中,我必须自定义绘制一个控件,为此我需要使用与 JButton 相同的字体颜色。 (启用和禁用)我不想对它们进行硬编码,因为用户可以在运行时更改 Substance 皮肤。

我知道ColorSchemes,但是一旦我有了当前皮肤的配色方案,我不确定如何继续。 Substance 文档还提到了有关创建自己的配色方案的内容,但我就是无法弄清楚检索某种颜色的方法。

【问题讨论】:

    标签: java swing substance


    【解决方案1】:

    好吧,终于我自己想通了:

    重要的一步是找出正确的配色方案。因为在 Substance 中每个根窗格都可以有自己的皮肤,所以最好使用 getCurrentSkinhelper。

    SubstanceColorScheme s = SubstanceLookAndFeel
            .getCurrentSkin(myComponent)
            .getEnabledColorScheme(
                    SubstanceLookAndFeel.getDecorationType(myComponent)
             );
    

    其他可能性是getDisabledColorSchemegetActiveColorSchemegetBackgroundColorScheme

    然后您可以使用s.getForegroundColorSubstanceColorUtilities 中的各种辅助方法。

    【讨论】:

      【解决方案2】:

      您为什么不在 Substance 论坛上询问 Kirill(Substance 的创建者)https://substance.dev.java.net/servlets/ProjectForumView

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-12-17
        • 2021-10-13
        • 2011-09-05
        • 2014-08-05
        • 1970-01-01
        相关资源
        最近更新 更多