1-3: Drawing Text
Problem
You want to draw text onto the JavaFX scene graph.
Solution
Create Text
nodes to be placed on the JavaFX scene graph by utilizing the javafx.scene.text.Text
class. As Text
nodes are to be placed on the scene graph, you decide you want to create randomly positioned Text
nodes rotated around their (x, y) positions scattered about the scene area.
The following code implements a JavaFX application that displays Text
nodes scattered about the scene graph with random positions and colors:
package javafx2introbyexample.chapter1.recipe1_03;
import java.util.Random;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.Text; import ...
Get JavaFX 2.0: Introduction by Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.