title: How to set a font to a Timeline in javafx
body: <p>I am making an alarm clock kind of program and I need a way to make the clock face a specific font. I have tried multiple times in multiple ways. If that is not possible can you please provide another solution? Thank you in advance!</p>
  
  <pre><code>import java.util.Calendar;
  import java.util.GregorianCalendar;
  
  import javax.print.DocFlavor.URL;
  
  import javafx.animation.Animation;
  import javafx.animation.KeyFrame;
  import javafx.animation.Timeline;
  import javafx.application.Application;
  import javafx.beans.value.ObservableValue;
  import javafx.event.ActionEvent;
  import javafx.event.EventHandler;
  import javafx.geometry.HPos;
  import javafx.geometry.Insets;
  import javafx.geometry.Pos;
  import javafx.scene.Group;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.control.Label;
  import javafx.scene.image.Image;
  import javafx.scene.layout.GridPane;
  import javafx.scene.layout.StackPane;
  import javafx.scene.paint.Color;
  import javafx.scene.shape.Line;
  import javafx.scene.shape.Rectangle;
  import javafx.scene.text.Font;
  import javafx.scene.text.FontWeight;
  import javafx.scene.text.Text;
  import javafx.stage.Stage;
  import javafx.util.Duration;
  
  public class Menu extends Application {
      @Override
      public void start(Stage primaryStage) throws Exception {
  
      //Frame stuff (works)
      GridPane grid = new GridPane();
      grid.setAlignment(Pos.CENTER);
      grid.setHgap(10);
      grid.setVgap(10);
  
      //Frame Size
      Scene scene = new Scene(new DigitalClock(),1080, 720);
  
      //Icon
      primaryStage.getIcons().add(new Image(getClass().getResourceAsStream(("/lib/logo.png"))));
      primaryStage.setTitle("Clock: 140 Edition");
  
      //Necessities
      primaryStage.setScene(scene);
      primaryStage.show();
  }
  
  public static void main(String args[]) {
      launch(args);
  }
  
  }
  
  class Util {
      public static String pad(int fieldWidth, char padChar, String s) {
          StringBuilder sb = new StringBuilder();
          for (int i = s.length(); i &lt; fieldWidth; i++) {
            sb.append(padChar);
          }
          sb.append(s);
  
          return sb.toString();
          }
  }
  
  class DigitalClock extends Label {
  
      public DigitalClock() {
          bindToTime();
          }
  
      // the digital clock updates once a second.
      private void bindToTime() {
      Timeline timeline = new Timeline(
        new KeyFrame(Duration.seconds(0),
          new EventHandler&lt;ActionEvent&gt;() {
            @Override public void handle(ActionEvent actionEvent) {
              Calendar time = Calendar.getInstance();
              String hourString = Util.pad(2, ' ', time.get(Calendar.HOUR) == 0 ? "12" : time.get(Calendar.HOUR) + "");
              String minuteString = Util.pad(2, '0', time.get(Calendar.MINUTE) + "");
              String secondString = Util.pad(2, '0', time.get(Calendar.SECOND) + "");
              String ampmString = time.get(Calendar.AM_PM) == Calendar.AM ? "AM" : "PM";
              setText(hourString + ":" + minuteString + ":" + secondString + " " + ampmString);
            }
          }
        ),
        new KeyFrame(Duration.seconds(1))
      );
      timeline.setCycleCount(Animation.INDEFINITE);
      timeline.play();
      }
  </code></pre>
  
  <p>I also know some of the imports are not used, I would prefer to keep them. Thanks again!</p>