Java Reference
In-Depth Information
There's more...
In CSS, the pseudo-class allows you to designate the behavior of the entity receiving the style
when there is interaction with the user. JavaFX's CSS has out-of-the-box support for pseudo-
classes including :hover , :pressed , and :focused . As you might imagine, you use these
pseudo-classes to specify the styles when a component is hovered, pressed, or receives focus
respectively, as demonstrated in the next code snippet:
.myButton:hover {
Cascading styles
JavaFX CSS supports styles that can be cascaded, using a combination of the selectors
identified earlier:
F Text#titleText{} —this selector defines styles to be applied only to a Text
instance with property id set to "titleText" .
F Rectangle.broad{} —applies the style only to Rectangle types with property
styleClass set to "broad" .
F .broad:hover{} —this selector defines the hover behavior only for node instances
with their styleClass property set to "broad" .
These can be chained in any combination to define fine-grained style rules which will be
applied to entities which meet the rule criteria.
See also
F Introduction
F Styling your applications with CSS
Skinning applications with multiple CSS files
The benefit of externalizing CSS is the ability to update the look and feel of your application
without having to update the code or recompile. Another attractive aspect of externalizing CSS
is to let your users select a preferred theme or applying a skin. In this recipe, we are going to
extend the data input form example, used throughout this chapter, to add skinning capabilities
with CSS.
Search WWH ::

Custom Search