Java Reference
In-Depth Information
example file. In NetBeans, you can select Clean and Build Project or you can copy files
to your classes' build area.
Now that you know how to load CSS styles, let's talk about the JavaFX CSS select-
ors and styling properties. Like CSS style sheets, there are selectors or style classes as-
sociated with Node objects in the scene graph. All scene graph nodes have a method
called setStyle() that applies styling properties that could potentially change the
node's background color, border, stroke, and so on. Because all graph nodes extend
from the Node class, derived classes will be able to inherit the same styling properties.
Knowing the inheritance hierarchy of node types is very important because the type of
node will determine the types of styling properties you can affect. For instance, a
Rectangle extends from Shape , which extends from Node . The inheritance does
not include -fx-border-style , which is the part of node that extends from Re-
gion . Based on the type of node, there are limitations to what styles you are able to
set. To see a full list of all the style selectors, refer to the JavaFX CSS Reference
Guide:
http://docs.oracle.com/javase/8/javafx/api/javafx/scene/
doc-files/cssref.html
All JavaFX styling properties are prefixed with -fx- . For example, all Node s
have the styling property to affect opacity, and that attribute is -fx-opacity . Fol-
lowing are selectors that style the JavaFX javafx.scene.control.Label s and
javafx.scene.control.Button s:
.label {
-fx-text-fill: rgba(17, 145, 213);
-fx-border-color: rgba(255, 255, 255, .80);
-fx-border-radius: 8;
-fx-padding: 6 6 6 6;
-fx-font: bold italic 20pt "LucidaBrightDemiBold";
}
.button{
-fx-text-fill: rgba(17, 145, 213);
-fx-border-color: rgba(255, 255, 255, .80);
-fx-border-radius: 8;
Search WWH ::




Custom Search