B4J Question Font Size

micro

Well-Known Member
Licensed User
Longtime User
Hi to all
I have a textfield created with javafx call numtxt.
With B4j I added this code to increase the font size
Code: Copy
numtxt.Style = "-fx-font-size: 24;"
But it's not work, It's correct?
 
Hi to all
I have a textfield created with javafx call numtxt.
With B4j I added this code to increase the font size
Code: Copy
numtxt.Style = "-fx-font-size: 24;"
But it's not work, It's correct?

Micro,
I use the same thing and it works for me. You didn't say what happened, but one thing you must make sure of is that the numtxt label is large enough to hold the larger text otherwise it may just look blank or have dots in it.
 
Upvote 0
Hi to all
I have a textfield created with javafx call numtxt.
With B4j I added this code to increase the font size
Code: Copy
numtxt.Style = "-fx-font-size: 24;"
But it's not work, It's correct?

micro,
Another thing I discovered is that you cannot do this with two statements:

Code: Copy
QuitButton.Style = "-fx-font-size: 30;"
QuitButton.Style = "-fx-text-fill: Yellow;" & "-fx-Font-weight: bold;" & _
"-fx-background-color: linear-gradient(DarkRed, Red);" & _
"-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0 , 1 );"

Everything must be in the same statement like this:

Code: Copy
QuitButton.Style = "-fx-font-size: 30;" & "-fx-text-fill: Yellow;" & "-fx-Font-weight: bold;" & _
"-fx-background-color: linear-gradient(DarkRed, Red);" & _
"-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0 , 1 );"

Apparently only the last statement has any effect. The first one is ignored according to my testing.
 
Upvote 0
micro,
Open your form in Scene Builder and click on the label you put in the form. On the right side of the screen at the top you will see Properties. Click on the little black arrow to expand the properties. Look for the word Font. That's where you set it.
 
Upvote 0
Label seems to be one of the few Nodes (controls) that even has such a property.

I find it more useful and more consistently available to set the Style property instead. You can also see this in the Scene Builder Properties. Bonus: many styles are inherited so you can set something like a default font at the "Form" (AnchorPane, etc.) level along with the Pane color and other styles, e.g.:

-fx-background-color: lightgray; -fx-font: 14pt Arial

Oddly enough, the Scene Builder (version 1.1 anyway) seems to have a weird bug where setting the AnchorPane's Style as shown above results in a child Label's Font Property being shown as Arial 14px!
 
Upvote 0
Back
Top