O'Reilly logo

JavaFX 2.0: Introduction by Example by Carl Dea

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required