package jira; import java.util.Locale; import javafx.application.Application; import javafx.application.Platform; import javafx.scene.Scene; import javafx.scene.control.*; import javafx.scene.layout.VBox; import javafx.stage.Stage; import javafx.scene.text.Font; import javafx.geometry.Insets; public class RT35322 extends Application { public static void main(String[] args) { Locale.setDefault(Locale.forLanguageTag("sk-SK")); launch(args); } Scene scene; @Override public void start(Stage stage) throws Exception { VBox root = new VBox(10); root.setPadding(new Insets(10, 10, 10, 10)); Locale locale = Locale.getDefault(); Label localeLabel = new Label(locale.toString()); Label label = new Label("Lorem ipsum dolor sit amet."); root.getChildren().addAll(localeLabel, label); final ToggleGroup group = new ToggleGroup(); String[] fonts = { "Source Sans Pro ExtraLight", "http://themes.googleusercontent.com/static/fonts/sourcesanspro/v7/toadOcfmlt9b38dHJxOBGMa9awK0IKUjIWABZIchFI8.woff", "Source Sans Pro Light", "http://themes.googleusercontent.com/static/fonts/sourcesanspro/v7/toadOcfmlt9b38dHJxOBGNbE_oMaV8t2eFeISPpzbdE.woff", "Source Sans Pro", "http://themes.googleusercontent.com/static/fonts/sourcesanspro/v7/ODelI1aHBYDBqgeIAH2zlBM0YzuT7MdOe03otPbuUS0.woff", "Source Sans Pro Semibold", "http://themes.googleusercontent.com/static/fonts/sourcesanspro/v7/toadOcfmlt9b38dHJxOBGJ6-ys_j0H4QL65VLqzI3wI.woff" }; for (int i = 0; i < fonts.length; i+=2) { String font = fonts[i]; RadioButton rb = new RadioButton(font); rb.setToggleGroup(group); rb.setUserData(fonts[i + 1]); root.getChildren().add(rb); } group.selectedToggleProperty().addListener(l -> { Toggle selected = group.getSelectedToggle(); if (selected != null) { String url = (String)selected.getUserData(); boolean backgroundThread = true; if (backgroundThread) { new Thread(() -> { System.out.println("Creating font in background thread " + url); Font font = Font.loadFont(url, 20); System.out.println("Font " + font); Platform.runLater(() -> { label.setFont(font); System.out.println("Setting font on label (runLater) " + font); }); }).start(); } else { Font font = Font.loadFont(url, 20); System.out.println("Font " + font); label.setFont(font); } } }); scene = new Scene(root, 300, 200); stage.setScene(scene); stage.show(); } }