Game Development Reference
In-Depth Information
> java.lang.Object
> javafx.application.Application
> invincibagel.
InvinciBagel
By extending the javafx.application package and its Application class, you will
give the InvinciBagel class everything it needs to host (or run) the JavaFX application.
The
J
avaFX Application class “constructs” an
Application
object so that it can use
system memory; call an
.init()
method, to initialize anything that may require initializ-
ing; and call a
.start()
method (see
Figure 3-2
,
second-outermost red box), which puts
things into place that will ultimately be needed to fire up (start) an InvinciBagel Java 8
game application.
When the end user finishes using the InvinciBagel game a
pplication
, the
Applica-
tion
object, created by the
Application
class, using the
Application()
constructor
method, will call its
.stop()
method and remove your application from system memory,
thus freeing up that memory space for other uses by the your end-users. You will be
learning about Java 8 methods, constructors, and objects soon, as you are progressing
from the high-level package and class constructs, to lower-level method and object
constructs, and so you are moving from a high-level overview to lower levels. You may
be wondering if Java classes can be
nested
inside each other, that is, if Java classes
contain other Java classes. The answer is yes, they certainly can (and do)! Let's take a
look at the concept of Java nested classes next.
Nested Classes: Java Classes Living Inside Other
Classes
A
nested class
in Java is a class that is defined inside of another Java class. A nested
class is part of the class in which it is nested, and this nesting signifies that the two
classes are intended to be used together in some fashion. There are two types of nested
classes:
static nested classes
, which are commonly referred to simply as nested
classes, and
nonstatic nested classes
, which are commonly referred to as
inner
classes
.
Static nested classes, which I will refer to as nested classes, are used to create utilit-
ies for use with the class that contains them, and are sometimes used only to hold con-
stants for use with that class. Those of you who develop Android applications are very
familiar with nested classes, as they are quite commonly employed in the Android API,
to hold either utility methods or Android constants, which are used to define things
such as screen density settings, animation motion interpolation curve types, alignment