Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FXML Label text bold

Tags:

javafx

fxml

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.

like image 240
Delin Mathew Avatar asked Apr 13 '18 09:04

Delin Mathew


People also ask

How do I bold text in a JavaFX label?

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.

How do I change the text in a JavaFX label?

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.

How do I make text bold in Java?

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.


1 Answers

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));

like image 126
Matt Avatar answered Nov 29 '22 06:11

Matt