May 2018
Intermediate to advanced
268 pages
6h 43m
English
The last-but-not-least shape to cover is Text. Text draws letters in various fonts. Text weight, posture, and size are controlled by the Font API:
// chapter2/other/TextDemo.javaText txt = new Text("Hello, JavaFX!");txt.setFont(Font.font ("Courier New", FontWeight.BOLD, FontPosture.ITALIC, 20));
Text color is controlled through the standard setFill() method, which means we can use all functionality of Paint for text as well:
// gradient fill, see details few sections belowStop[] stops = new Stop[]{new Stop(0, Color.BLACK), new Stop(1, Color.DARKGRAY), new Stop(0.5, Color.ANTIQUEWHITE)};LinearGradient gradient = new LinearGradient(50, 50, 250, 50, false, CycleMethod.NO_CYCLE, stops);txt.setFill(gradient);
Read now
Unlock full access