Java Reference
In-Depth Information
Styling Paint properties with CSS
JavaFX lets you declare color styles in three ways, including the RGB hexadecimal, the color
name, and the RGB decimal values as shown in the following snippets:
Rectangle {
style:"fill :#33FFCC ;stroke: #0000FF ;"
Circle {
style:"fill: red ;stroke: blue ;"
MyCustomNode {
style:"fill: rgb(150,44,96 );stroke: rgb(255,55,148) ;"
The CSS engine also supports a shortcut notation that lets developers specify paint gradients:
Circle {
style:"fill: linear (100%, 0%)"
" to (0%,0%)"
" stops (0.0, red), (1.0, white);"
Rectangle {
style:"fill: radial (0%, 0%) , 50% focus(25%, 25%)"
" stops (0.00, red), (1.0, white);"
For linear gradients, JavaFX's CSS has the linear(startX,startY) , to(endX, endY) ,
and stops(offset,color) directives to build the gradient. For radial gradients, JavaFX
provides the radial(centerX,centerY) , radius-value focus(focusX,focusY) ,
and the stops(offset, color) directives.
See also
F Chapter 3—Applying cool paint effects with gradients
F Introduction
F Creating a form with JavaFX controls
Search WWH ::

Custom Search