Java Reference
In-Depth Information
The choice for null or
Color.TRANSPARENT
does not matter for a
Scene
; how-
ever, it does matter later on with
Nodes
. The main difference is that mouse events
will not be delivered to a node with a null fill when the mouse is over the invisi-
ble part of the node. On the other hand, if the fill is
Color.TRANSPARENT
, mouse
events will be delivered to the node, even if the mouse is over the invisible part.
This is because
Color.TRANSPARENT
is actually a valid color being black with
opacity of zero—therefore, it is a color that appears invisible.
In addition to the fill paint, the scene also allows you to set the
Cursor
style for
the entire scene. The default is null indicating that the System default cursor will
be used. The options from the
javafx.scene.Cursor
class are
default
,
wait
,
crosshair
,
hand
,
move
, and
text
. There is also a set for the resize cursors based
on compass direction:
east
,
north
,
northeast
,
northwest
,
west
,
southwest
,
south
, and
southeast
, and
vertical
and
horizontal
. Of course, there is also
an option for no cursor at all.
Cascading style sheets (CSS) are commonly used on the Web to partition content
from presentation. This provides flexibility to easily change the presentation
qualities without modifying the code that provides the basic content and behav-
ior. A style sheet is a set of rules that control how to display elements. Each rule
is made up of a selector that matches an element and a set of properties with val-
ues that define the presentation settings for the selected element. JavaFX
includes support for style sheets, but there are some minor differences from their
HTML cousins.
The most obvious difference is that instead of using HTML or XML elements for
the selector, JavaFX uses the JavaFX class names. These can be fully qualified
class names enclosed in double quotes, or for the standard JavaFX user interface
classes, you can just use the base class name. For example,
javafx.scene
.shape.Rectangle
or
Rectangle
will resolve equally.
For CSS ID selectors, instead of using the XML
id
attribute, JavaFX uses the
Node
's
id
variable. CSS class selectors are similar to the way they are used in
HTML. CSS pseudo-classes are defined on certain Boolean instance variables
within the JavaFX
Control
and
Skin
classes. To use a style sheet, include its
URL in the
Scene's stylesheet
instance variable. There may be zero or more
style sheet URL strings.
There are several ways to use a style on a display node. First, you can set the node's
id
attribute to match the CSS ID selector. Secondly, you can include the style in
Search WWH ::
Custom Search