Search code examples
javacssjavafxexternalstylesheet

JavaFX children edit without external css files


I am trying to edit a design of the ProgressIndicator.

In code i can set the style, but it seems that I can't reach the children such as

.progress . I know i can change the style using custom css stylesheet but is there a way to do this without external files?

I am trying to change the color of the #progress child.

Thank you


Solution

  • The layout of most controls are done through their skin.

    This should work, provided the scene graph is already built (lookup can run).

    StackPane progress = (StackPane) progressIndicator.getSkin().lookup(".progress");
    progress.setStyle("mystyle");