import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.TextArea; import javafx.scene.layout.FlowPane; import javafx.scene.layout.Pane; import javafx.scene.text.Font; import javafx.stage.Stage; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author Pavel Zernov */ public class FxCssSingleTest_1 extends Application { //public static final String cssPath = "custom_font.css"; public static final String fontPath = "arialw7.ttf"; public static final String cssPath = "custom_font_1.css"; public static final String INITIAL_TEXT = "JavaFX"; final TextArea testText = new TextArea(INITIAL_TEXT); public void start(Stage stage) { stage.setWidth(200); stage.setHeight(200); Pane p = new FlowPane(); Scene scene = new Scene(p); stage.setScene(scene); Font.loadFont(FxCssSingleTest_1.class.getResourceAsStream(fontPath), 12); String cssFontUrl = FxCssSingleTest_1.class.getResource(cssPath).toExternalForm(); scene.getStylesheets().add(cssFontUrl); p.getChildren().add(testText); stage.show(); } public static void main(String[] args) { Application.launch(FxCssSingleTest_1.class, args); } }