【问题标题】:How to change the highlighting color in JavaFX?如何更改 JavaFX 中的突出显示颜色?
【发布时间】:2012-12-17 01:56:35
【问题描述】:

如何更改 JavaFX 中的突出显示颜色?通常它是带有渐变的蓝色,但我想要绿色突出显示。我尝试了以下方法:

.root{
    -fx-shadow-highlight-color: #CCFF99;
}

感谢您的帮助!

【问题讨论】:

    标签: java css javafx-2 javafx


    【解决方案1】:

    我认为 Uluk Biy 的回答很好。

    但现实情况是使用 CSS 进行样式设置不会覆盖 -fx-focus-color:#0093ff,而是会重叠。如果您使用 -fx-focus-color: red ,它将与默认的蓝色混合并显示类似灰色的颜色。 css 属性 -fx-accent 没有问题。

    【讨论】:

      【解决方案2】:

      您也可以在text-area 类选择器上使用-fx-highlight-fill

      .text-area {
          -fx-highlight-fill: green;
      }
      

      【讨论】:

        【解决方案3】:

        查看 caspian.css (JavaFX 2) 或 modena.css (JavaFX 8)

        .root {
            /* A bright blue for highlighting/accenting objects.  For example: selected
             * text; selected items in menus, lists, trees, and tables; progress bars;
             * default buttons.
             */
            -fx-accent: #0093ff;
        
            /* A bright blue for the focus indicator of objects. Typically used as the
             * first color in -fx-background-color for the "focused" pseudo-class. Also
             * typically used with insets of -1.4 to provide a glowing effect.
             *
             * TODO: should this be derived from -fx-accent?
             */
            -fx-focus-color: #0093ff;
        }
        

        根据用途更改这些颜色。

        【讨论】:

        • 非常感谢!我应该手动更改 ListViews 的悬停背景吗?或者有没有办法像 -fx-accent 一样将它们全局更改?
        • ListView 悬停颜色为:-fx-cell-hover-color - 它也可以在 caspian.css - here is a link to the 2.2 version 中找到
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-02-02
        • 2010-12-12
        • 2012-03-27
        • 2011-06-19
        • 2012-10-24
        • 1970-01-01
        • 2018-03-19
        相关资源
        最近更新 更多