O'Reilly logo

JavaFX 1.2 Application Development Cookbook by Vladimir Vivien

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

Adding depth with lighting and shadow effects

All of the shapes we have used so far have been rendered pretty bland with boring solid colors. Let's say you want to enhance the look of your objects by adding depth for a more engaging look. This recipe shows you how to use the Effect classes to add lighting and shadow effects to visual nodes in the scene graph.

Getting ready

All Node instances can receive an effect through the effect:Effect property. You can find all effects in the package javafx.scene.effect. For this recipe, we are going to use effects classes Lighting, DistantLighting, and DropShadow.

How to do it...

The abbreviated code listing given next shows you how to use the Lighting and the DropShadow effects to enhance the appearance of a ...

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