JavaFX CSS "dynamic" value not being used
-
I'm having a weird problem with my CSS. If I go into the file and set the following two properties manually, it is working, but if I set them from java code (.setStyle()), for some reason they aren't being used. Properties: -fx-font-family -fx-font-size So if in the file I use the following syntax it is working fine:
-fx-font-family: "Blackadder ITC";
-fx-font-size: 18;I used that font family because it is clear to see if it is changed or not. Then I changed that with the following set to be able to change the font (family and size) straight from my java code.
-fx-font-family: fontFam;
-fx-font-size: fontDim;In java code I have this:
String fontFam = "Blackadder ITC";
int fontDim = 18;
.setStyle("fontFam: \"" + fontFam + "\"; fontDim: " + fontDim + ";");I have other css properties in this .setStyle (to set some rgba colors), and they are working fine, the problem is only with the font. The first problem is that the font family doesn't get applied, and the second one is the font size, I'm getting the following warning: WARNING: CSS Error parsing file: file location: Expected '' while parsing '-fx-font-size' at [6,16] Unfortunately I can't simply use .setFont for this, because it is part of DataPicker, more precise it's TextField. Isn't this the way you are suppose to do it, or for font property I have to do something different?
-
I'm having a weird problem with my CSS. If I go into the file and set the following two properties manually, it is working, but if I set them from java code (.setStyle()), for some reason they aren't being used. Properties: -fx-font-family -fx-font-size So if in the file I use the following syntax it is working fine:
-fx-font-family: "Blackadder ITC";
-fx-font-size: 18;I used that font family because it is clear to see if it is changed or not. Then I changed that with the following set to be able to change the font (family and size) straight from my java code.
-fx-font-family: fontFam;
-fx-font-size: fontDim;In java code I have this:
String fontFam = "Blackadder ITC";
int fontDim = 18;
.setStyle("fontFam: \"" + fontFam + "\"; fontDim: " + fontDim + ";");I have other css properties in this .setStyle (to set some rgba colors), and they are working fine, the problem is only with the font. The first problem is that the font family doesn't get applied, and the second one is the font size, I'm getting the following warning: WARNING: CSS Error parsing file: file location: Expected '' while parsing '-fx-font-size' at [6,16] Unfortunately I can't simply use .setFont for this, because it is part of DataPicker, more precise it's TextField. Isn't this the way you are suppose to do it, or for font property I have to do something different?
I've done some more testing, and I got some strange results. I tried the following code, and it wasn't working either for font.
* {
fontFO: "Blackadder ITC";
fontSI: 18;
}.date-picker > .text-field {
-fx-font-family: fontFO;
-fx-font-size: fontSI;
}The fontFO didn't had any effect, it used it's default font family, and using the fontSI, I was getting the same warring as in my previous post. So I'm left with 2 questions. 1. Can you use "looked-up"/dynamic values (or how they are actually named, I'm not that good at CSS), only for colors? 2. What other choice/method do I have to send values to a CSS file? I want to give the option to the user to change the font family and font size to whatever they want.