I was not sure if it was me, that was not using the right attributes to style controls via CSS. But today I tested one example from the Ensemble application and noticed it was not working there either.
The one I find most difficult to set right is: -fx-text-fill
To change the text color of a label for example:
#pill-left:selected .label {
/* -fx-text-fill: black; */
-fx-text-fill:red;
-fx-effect: dropshadow( one-pass-box , white , 0, 0.0 , 0 , 1 );
}
No matter what I put there, the text always uses the default value color.
I’m using JavaFx 2.1. Maybe this is already fixed in 2.2, but I figure I should point that out, as it is something very basic.
Ok, after some extensive testing, I managed to make it work using StyleSheets.
The key is to remove the .label attribute and use just the control’s ID, appending the states (:hover, :selected, etc) as needed.
As this is all based on code examples taken directly from the ensemble project, that we assume is correct. Many programmers are going to find themselves pulling their hair like I did over this issue.
Anyhow, this is an important lesson learnt on how to use styleSheets with Javafx, avoiding when possible to use anything else than the ID to specify some attributes like the text color.