Game Development Reference
In-Depth Information
known as a
compound statement
, as you learned in the previous chapter. The Java
code for this declaration can be seen at the top of the class in
Figure 9-1
, and should
look like the following:
static final double
WIDTH
= 640,
HEIGHT
= 400;
Figure 9-1
.
Add private static final double WIDTH and HEIGHT constants; install these, and Color.WHITE, in
Scene()
The next thing that we will want to do is the upgrade our Stage() constructor meth-
od call, to use one of the other overloaded constructor methods that allows us to also
specify the
background color
value. Let's use the
Color
class constant of
WHITE
,
and our new width and height display screen size constants, and create this new con-
structor method call, using the following line of Java code, which is also shown (laden
with errors) at the bottom of
Figure 9-1
:
scene = new Scene(root,
WIDTH
,
HEIGHT
,
Color.WHITE
);
As you can see in
Figure 9-1
, you will have a wavy red error underline under your
Color
class reference, until you use the
Alt-Enter
work process to bring up the helper
dialog (as shown), and select the option that specifies “Add import for
javafx.scene.paint.Color” in order to have NetBeans write the Java import statement
for you. Once you do this, your code will be error free, and we will be ready to write
some code that will put this background color in place.