Java Reference
In-Depth Information
Figure 14-9 . Generating borders
How It Works
JavaFX is capable of styling JavaFX nodes similar to Cascading Style Sheets (CSS) in
the world of web development (also demonstrated in Recipe 14-3). This powerful API
can alter a node's background color, font, border, and many other attributes, essentially
allowing the developer or designer to skin GUI controls using CSS.
This solution to this recipe allows users to enter JavaFX CSS styles in the left text
area and, by clicking the Bling! button on the UI, apply the style around the image
shown to the right. Based on the type of node, there are limitations to what styles can
be set. To see a full listing of all style selectors, refer to the JavaFX CSS Reference
Guide:
http://docs.oracle.com/javase/8/javafx/api/javafx/scene/
doc-files/cssref.html .
In the first step of applying JavaFX CSS styles, you must determine which type of
node you want to style. When setting attributes on various node types, you will discov-
er that certain nodes have limitations. In this recipe, the intent was to put a border
around the ImageView object. Because ImageView is not extending from Region ,
it doesn't contain border style properties. So, to resolve this, simply create an HBox
layout to contain the imageView and apply the JavaFX CSS against the HBox . The
 
Search WWH ::




Custom Search