Java Reference
In-Depth Information
A third alternative is to use an in-line string with the style settings. This is done
using the style instance variable in the display node's object literal. For
instance, Listing 5.10 shows using a style with a Text node.
Listing 5.10
Node Style Instance Variable
/* Main.fx */
...
...
Text {
style: "fill: navy; "
"font:bold italic 35pt sans-serif;"
x: 10, y: 30
content: "This shows my style"
}
...
When using the node's style variable, the style is applied to all the nodes in the
scene graph starting with the node that contains the style declaration. For exam-
ple, if the node is a Group , the style is applied to the group node and all the nodes
defined as children contained in the group's content sequence. So, if you have a
group that contains many text objects, setting the fill style would apply to all
the text instances. If you need finer control over this, use either a styleClass or
ID selector defined in a style sheet.
CSS Pseudo Class
Pseudo classes are supported for classes that extend javafx.scene.control
.Control and javafx.scene.control.Skin . The currently supported pseudo
classes are :hover, :focused, :disabled, and :pressed. The pseudo class :hover
indicates that the style is active when the mouse if over the control; :focused is
active when the control has the keyboard focus; :pressed is active when the
mouse is pressed while over the control; and :disabled is active when the node is
marked as disabled.
Listing 5.11 shows examples of using these CSS pseudo classes with javafx
.scene.control.TextBox .
Listing 5.11
Style Sheet - JavaFX Supported Pseudo Classes
TextBox:hover {
background-fill: red;
text-fill: yellow;
}
 
Search WWH ::




Custom Search