Reputation: 13
Im very new to CSS since I was never working with weblanguages but for a JavaFX application I've got a css style sheet with a windows 10 UWP theme. The default style classes use the default windows grey button theme, but i also created a custom style class for colored components.
The colors are as variables in the the .root style class for the default style and are overwritten in the .colored style class for the colored style.
.root
{
-fill-color: #CCCCCC;
...
}
.colored
{
-fill-color: #DD2867;
...
}
I now want to change the colored style colors at runtime. I know about Node#setStyle(String) in which i can modify the fill color with something like this:
root.setStyle("-fill-color: #FF00FF;");
but this has only an effect on the color in the .root style class and not the .colored style class.
Can you tell me a way to direcly modify a property of a style class at runtime or maybe an even better approach to use a default and a colored style?
Thanks in advance, Eleom.
Upvotes: 1
Views: 1965
Reputation: 209320
Define another looked-up color on the root node, and use it in your .colored
class:
{
-fill-color: #CCCCCC;
-colored-fill: #DD2867 ;
...
}
.colored
{
-fill-color: -colored-fill;
...
}
Then you can change that color programmatically the same way:
root.setStyle("-colored-fill: ... ;");
Upvotes: 1