Can someone please tell me how to make the text inside a label bold in Java FXML?
<Label fx:id="LegalLabel" text= "Legal Information" GridPane.halignment="RIGHT" GridPane.rowIndex="16" />
Thank you.
To make the text look bold, use the FontWeight constant of the font method as shown in Example 8. t. setFont(Font. font("Verdana", FontWeight.
Set Label Font You can change the font used by a JavaFX Label by calling its setFont() method. This is useful if you need to change the size of the text, or want to use a different text style.
To make a text bold create a font bypassing FontWeight. BOLD or, FontWeight. EXTRA_BOLD as the value of the parameter weight and, to make a text italic pass FontPosture. ITALIC as the value of the parameter posture.
Give this a shot
legalLabel.setStyle("-fx-font-weight: bold;");
or try making your fxml look like this
<Label fx:id="LegalLabel" text= "Legal Information" GridPane.halignment="RIGHT" GridPane.rowIndex="16">
<font>
<Font name="System Bold" size="13.0" />
</font>
</Label>
Edit: try this: legalLabel.setFont(Font.font("Verdana", FontWeight.BOLD, 12));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With