FXML Label text bold
Asked Answered
C

1

8

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.

Caresa answered 13/4, 2018 at 9:41 Comment(5)
Add this in your fxml style="-fx-font-weight: bold;" or this in your css stylesheet : .label { -fx-font-weight: bold;}. With a light research, you should have found this.Concertgoer
@Concertgoer Thank you for your answers. :) I had found this and had tried this, but it did not work. No idea why. Then I started to doubt my fxml skills as I'm clearly new to it. Therefore, posted the question. :)Caresa
Use SceneBuilderAstronaut
On my computer Java FX doesn't apply bold style to text with "System" font at all (Java 8u92 32-bit, WinXP). So I have to use "Arial Bold" instead. Maybe it is your case.Buoyant
@Buoyant From what I can tell, it does apply the style, but the font doesn't actually change at all. The same goes for italic and italic bold System font.Magneton
C
16

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

Crapshooter answered 13/4, 2018 at 20:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.