Java Reference
In-Depth Information
TextBox:pressed {
background-fill: navy;
text-fill: white;
}
TextBox:focused {
background-fill: purple;
text-fill: yellow;
}
When the TextBox has the focus, it will have a purple background with yellow
text. When the mouse moves over the TextBox , the background changes to red,
and the text changes to yellow. When the mouse is pressed in the TextBox , the
background changes to navy blue and the text to white. (Who chose these colors?)
To implement these pseudo classes in custom controls and skins, the custom
code must set the value for the corresponding properties. An example is provided
in the section Custom Controls, later in this chapter.
CSS Properties
In the StyleSheet file, the properties map directly to instance variables within the
specified JavaFX class. In the preceding example, the CSS properties ( fill and
font ) map directly to the instance variables fill and font in the javafx.scene
.text.Text class. CSS type properties like background-fill would map to a
JavaFX instance variable backgroundFill . The hyphen is removed and the sec-
ond word is capitalized.
The allowed property values are decimal number, integer, string, color, paint, or
font. Strings are enclosed in quotes.
Colors
Colors may be represented with a color name, (e.g., gray , red , or black ), a hexa-
decimal triplet beginning with a sharp (#) sign, #808080 , or using a function-like
syntax, rgb ( red , green, blue ) —for example, rgb(128, 128, 128) .
Paint
Paint may either be linear or radial .
linear maps to the javafx.scene.paint.LinearGradient class.
linear (startX, startY) to (endX, endY) stops
(offset, color), (offset, color), ... [reflect|repeat]
Search WWH ::




Custom Search