2 Replies Latest reply: Mar 5, 2012 3:54 PM by Richard Bair-Oracle RSS

    Font.loadFont doesn't work

      I'm trying to set a custom font in one of my labels but it doesn't seem to work... Here's the code I'm using.

      // file: LoginWindow.fxml


      <GridPane xmlns:fx="http://javafx.com/fxml" alignment="center" fx:id="myGridPane" hgap="10" vgap="10" fx:controller="br.com.vieirawebstudio.controllers.LoginWindowController">
      <Label fx:id="lblAppName" text="%appName" GridPane.halignment="center" GridPane.columnIndex="0" GridPane.rowIndex="0"/>


      // file: LoginWindowController.java

      import javafx.fxml.FXML;
      import javafx.fxml.Initializable;
      import javafx.scene.control.Label;
      import javafx.scene.text.Font;

      public class LoginWindowController implements Initializable

      @FXML private Label lblAppName;


      Font myFont = Font.loadFont(getClass().getResourceAsStream("/fonts/seven_days.ttf"), 120);

                if(myFont != null)


      But it doesn't work. What I'm doing wrong? Cheers