Java Reference
In-Depth Information
BorderPane root = new BorderPane(sphere, null, null, hbox, null);
scene = new Scene(root, 640, 480);
}
}
}
In this example, we added a color picker and two combo boxes to the bottom of the GUI, allowing you to change
the
material
,
drawMode
, and
cullFace
properties in the
model
. The
sphere
is shown in the middle of the GUI. The
sphere
's
material
,
drawMode
, and
cullFace
properties are bound to a similar property in
model
. Therefore the user's
choice is reflected in the
sphere
.
When the program in Listing 10-2 is run, the Shape3D Properties Example window in Figure
10-2
is displayed.
A wireframe of the sphere is shown.
Figure 10-2.
The Shape3DPropertiesExample program
Creating Predefined 3D Shapes
The three predefined 3D shapes—
Sphere
,
Cylinder
, and
Box
—can be constructed and put into a JavaFX scene very
easily, as we saw for the
Sphere
class in the last section. In this section, we describe these classes in more detail.
The
Sphere
class has the following constructors:
Sphere()
•
Sphere(double radius)
•
Sphere(double radius, int divisions)
•
Search WWH ::
Custom Search