import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.scene.control.Label; import javafx.scene.text.Font; import javafx.scene.text.FontPosture; import javafx.scene.text.FontWeight; import javafx.scene.layout.VBox; public class LabelFontTest extends Application { private void init(Stage primaryStage) { Font font; String fontFamilyName = "System"; int size = 14; String labelString = "A simple label without a graphic."; Group root = new Group(); primaryStage.setScene(new Scene(root)); VBox vbox = new VBox(5); Label label1 = new Label("Regular: " + labelString); font = Font.font(fontFamilyName, FontPosture.REGULAR, size); System.out.println("Actual Font: " + font.getName()); label1.setFont(font); Label label2 = new Label("Bold: " + labelString); font = Font.font(fontFamilyName, FontWeight.BOLD, size); System.out.println("Actual Font: " + font.getName()); label2.setFont(font); Label label3 = new Label("Italic: " + labelString); font = Font.font(fontFamilyName, FontPosture.ITALIC, size); System.out.println("Actual Font: " + font.getName()); label3.setFont(font); Label label4 = new Label("Bold Italic: " + labelString); font = Font.font(fontFamilyName, FontWeight.BOLD, FontPosture.ITALIC, size); System.out.println("Actual Font: " + font.getName()); label4.setFont(font); vbox.getChildren().addAll(label1, label2, label3, label4); root.getChildren().add(vbox); } @Override public void start(Stage primaryStage) throws Exception { init(primaryStage); primaryStage.show(); } public static void main(String[] args) { launch(args); } }