Java Reference
In-Depth Information
23 primaryStage.show();
// Display the stage
24 }
25 }
F
IGURE
14.8
A pane's style is set and it is rotated 45 degrees.
As seen in Figure 14.8, the rotate on a pane causes all its containing nodes rotated too.
The
Node
class contains many useful methods that can be applied to all nodes. For example,
you can use the
contains(double x, double y)
method to test where a point (
x
,
y
) is
inside the boundary of a node.
contains
method
14.12
How do you set a style of a node with border color red? Modify the code to set the
text color for the button to red.
14.13
Can you rotate a pane, a text, or a button? Modify the code to rotate the button 15
degrees counterclockwise?
✓
✓
Check
Point
Key
Point
JavaFX defines the abstract
Paint
class for painting a node. The
javafx.scene.paint.Color
is a concrete subclass of
Paint
, which is used to encapsulate colors, as shown in Figure 14.9.
The getter methods for property
values are provided in the class, but
omitted in the UML diagram for brevity.
javafx.scene.paint.Color
-red: double
-green: double
-blue: double
-opacity: double
The red value of this Color (between
0.0
and
1.0
).
The green value of this Color (between
0.0
and
1.0
).
The blue value of this Color (between
0.0
and
1.0
).
The opacity of this Color (between
0.0
and
1.0
).
Creates a
Color
with the specified red, green, blue, and opacity values.
+Color(r: double, g: double, b:
double, opacity: double)
+brighter(): Color
+darker(): Color
+color(r: double, g: double, b:
double): Color
+color(r: double, g: double, b:
double, opacity: double): Color
+rgb(r: int, g: int, b: int):
Color
+rgb(r: int, g: int, b: int,
opacity: double): Color
Creates a
Color
that is a brighter version of this
Color
.
Creates a
Color
that is a darker version of this
Color
.
Creates an opaque
Color
with the specified red, green, and blue values.
Creates a
Color
with the specified red, green, blue, and opacity values.
Creates a
Color
with the specified red, green, and blue values in the
range from
0
to
255
.
Creates a
Color
with the specified red, green, and blue values in the
range from
0
to
255
and a given opacity.
F
IGURE
14.9
Color
encapsulates information about colors.
Search WWH ::
Custom Search