Java Reference
In-Depth Information
Ta b l e 6 . 1
Instance Variables for DropShadow
Default
Va l u e
Min
Va l u e
Max
Va l u e
Variable
Description
color
The color of the shadow
BLACK
n/a
n/a
offsetX
The offset (in pixels) in the
x
direction
0.0
n/a
n/a
offsetY
The shadow offset (in pixels) in the
y
direction
0.0
n/a
n/a
radius
The radius of the shadow blur in pixels
10.0
1.0
63.0
spread
The spread of the shadow
0.0
0.0
1.0
It is not necessary to define all of these variables each time you want to use
DropShadow
, as they default to values that you may find acceptable. As we run
through examples of other effects, explaining each of the instance variables in
detail would result in a very lengthy and cumbersome chapter. Instead, we'll
stick to easy-to-understand sample usages and suggest that for additional detail,
you consult the JavaFX API documentation.
So let's apply a
DropShadow
effect to our sample code. To do so, only two easy
insertions are required. The first involves letting the compiler know that the JavaFX
effects classes will be brought into play. This is done by including the following
import
statement alongside your other imports:
import javafx.scene.effect.*;
Next, comes the more interesting modification of setting the
Text
node's
effect
instance variable. So, for example, if you want to add a
DropShadow
effect to the
Text
node referenced earlier, the
effect
instance variable could look something
like
effect: DropShadow { offsetX: 3, offsetY: 3 }
Listing 6.1 shows the code for the original
Text
node enhanced to include a
DropShadow
effect, where the shadow offset is 3 pixels in the
x
and
y
direction.
The remaining unreferenced instance variables of the
DropShadow
effect are
assigned their default value.
Search WWH ::
Custom Search