Maybe a TitledPane bug

David Grieve david.grieve at
Thu Nov 1 18:49:56 UTC 2018

On 11/1/18 2:19 PM, Sverre Moe wrote:

> scene.getStylesheets().add(getClass().getResource("light.css").toExternalForm());
> Here is the CSS content for light.css
> .titled-pane > .title {
>     -fx-color: rgb(220, 220, 220);
Well, there you go. Your 'light.css' style trumps the setBackground. The 
reason for this is that this allows an application to be deployed with 
explicitly set, styleable properties - e.g. titleNode.setBackground(...) 
- but still allow that application to be styled from a stylesheet.

 From the JavaFX CSS reference:

The implementation allows designers to style an application by using style
     sheets to override property values set from code. This has implications for
     the cascade; particularly, when does a style from a style sheet override a
     value set from code? The JavaFX CSS implementation applies the following
     order of precedence; a style from a user agent style sheet has lower
     priority than a value set from code, which has lower priority than a Scene
     or Parent style sheet. Inline styles have highest precedence. Style sheets
     from a Parent instance are considered to be more specific than those styles
     from Scene style sheets.

More information about the openjfx-dev mailing list