Java Reference
In-Depth Information
effect: Shadow { radius: 10 }
the resulting output would look like Figure 6.5.
Figure 6.5
An Example of the Shadow Effect on Text
Here, we see that the content
becomes
the shadow without including the original
pre-effect text. Using
Shadow
, we could mimic the
DropShadow
effect seen in
Figure 6.2 by including two
Text
nodes, one using the
Shadow
effect with the
x
and
y
coordinates offset by 3 pixels, the other node just displaying the text at the
original coordinates. Nodes are displayed in the order they appear in the code, so
the node with the
Shadow
effect must appear before the plain
Text
node. Here's
how the JavaFX code segment would look:
Stage {
width: 250
height: 100
scene: Scene {
var xStart = 15;
var yStart = 40;
content: [
Text {
font: Font {
size: 32
}
x: xStart+3, y: yStart+3
content: "JavaFX effects"
effect: Shadow { radius: 10 }
}
Text {
font: Font {
size: 32
}
x: xStart, y: yStart
fill: Color.DARKRED
content: "JavaFX effects"
}
]
}
}
Search WWH ::
Custom Search