0

As far as I understand you can define "color variables" in the css.

Let's say, I have a color called "default-background-color", and I set all backgrounds to be this color.

-default-background-color: #d0d0d0;
[...]
.button{
    -fx-background-color: -default-background-color
}

Then, during runtime, I want to change this color to be something else, so that all backgrounds change to my new color.

How is this achieved without reloading a new css file?

Community
  • 1
  • 1
Maverick283
  • 1,284
  • 3
  • 16
  • 33

1 Answers1

2

You can change set the style programmatically on any node to change the value of the looked-up color. The new looked-up color value will propagate to all child nodes. So, for example

root.setStyle("-default-background-color: #d0d080;");
James_D
  • 201,275
  • 16
  • 291
  • 322