Game Development Reference
In-Depth Information
Next, let's take a look at JavaFX Scene Builder and how it uses FXML to allow de-
signers to design Java FX applications visually. I am not going to be using Scene
Builder or FXML (just Java 8 code and JavaFX classes) over the course of this topic,
so pay attention!
JavaFX Scene Builder: Using FXML for
UI Design
JavaFX Scene Builder is a visual design tool that generates an FXML (JavaFX
markup language) UI Scene Graph construct to define your JavaFX application's front-
end design. This FXML UI definition can then be “inflated” in Java 8 to create your
application's JavaFX Scene Graph, nodes, groups, and SubScene objects filled with
javafx.scene.control package classes (objects) defining your UI design. Oracle's inten-
tion in offering both a Scene Builder visual development tool and FXML is to allow
nonprogrammers, ostensibly UI designers, to design the front-end UIs for their Java 8
applications so that the Java programmers can then focus on back-end functional ap-
plication task processing logic.
Because FXML and Scene Builder are optimized for UI design (arranging controls,
such as buttons, text entry fields, radio buttons, check boxes, and so on), I am not going
to use Scene Builder and FXML over the course of this topic. I am, however, going to
cover it in this chapter so that you know how to use it if you want to for your other
JavaFX applications. My reasoning is that, other than the initial game splash screen,
which contains a few UI Button objects, which show game instructions, list the contrib-
utors, track the high scores, save a current game state, and start game play, UI design
will not be a major focus of this topic.
To use FXML, and soon after use of the Scene Builder visual UI design tool, you
must create a special kind of FXML application, as you learned in Chapter 2 (see Fig-
ure 2-4 ) , when you created the JavaFX game. Creating an FXML application imports
the javafx.fxml package and classes. This allows the Java 8 code to inflate FXML
constructs created by the UI designers so that they can be used by the programmers to
attach Java logic to the various UI controls. The Android OS does this as well, using
basic XML, but in Android this approach is not optional; it is part of the way things are
done. In JavaFX 8 (as you saw in Figure 2-4 ) , it is simply one option. If you want to re-
search XML-based UI design further for Android, check out my book Pro Android UI
(Apress, 2014).
Search WWH ::




Custom Search