/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. */ package test.scenegraph.app; import javafx.application.Application; import javafx.beans.InvalidationListener; import javafx.beans.Observable; import javafx.scene.control.Slider; import javafx.scene.text.Text; import javafx.scene.text.Font; import javafx.scene.Scene; import javafx.scene.layout.FlowPane; import javafx.scene.layout.Pane; import javafx.stage.Stage; /** * * @author shubov */ public class TestTextApp11 extends Application { public static final String INITIAL_TEXT = "JavaFX"; final Text testText = new Text(INITIAL_TEXT); public static final String fontPath = "/test/scenegraph/resources/arialw7.ttf"; public static final String cssPath = "/test/scenegraph/resources/custom_font.css"; public void start(Stage stage) { stage.setWidth(400); stage.setHeight(600); Pane p = new FlowPane(); Scene scene = new Scene(p); stage.setScene(scene); Font.loadFont(TestTextApp11.class.getResourceAsStream(fontPath), 12); String cssFontUrl = TestTextApp11.class.getResource(cssPath).toExternalForm(); scene.getStylesheets().add(cssFontUrl); final Slider slider1 = new Slider(10, 240, 22); slider1.valueProperty().addListener(new InvalidationListener() { @Override public void invalidated(Observable ov) { double xx = slider1.getValue(); testText.setFont(new Font(slider1.getValue())); System.out.println("size=" + xx); } }); p.getChildren().add(slider1); p.getChildren().add(testText); stage.show(); } public static void main(String[] args) { Application.launch(TestTextApp11.class, args); } }