1-4: Changing Text Fonts

Problem

You want to change text fonts and add special effect to Text nodes.

Solution

Create a JavaFX application that uses the following classes to set the text font and apply effects on Text nodes:

  • javafx.scene.text.Font
  • javafx.scene.effect.DropShadow
  • javafx.scene.effect.Reflection

The code that follows sets the font and applies effects to Text nodes. We will be using the Serif, SanSerif, Dialog, and Monospaced fonts along with the drop shadow and reflection effects:

package javafx2introbyexample.chapter1.recipe1_04; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.effect.DropShadow; import javafx.scene.effect.Reflection; import javafx.scene.paint.Color; ...

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.