Java Reference
In-Depth Information
What is FXML?
As you create and modify a GUI, JavaFX Scene Builder generates FXML (FX Markup
Language) —an XML vocabulary for defining and arranging JavaFX GUI controls with-
out writing any Java code. You do not need to know FXML or XML to study this chapter.
As you'll see in Section 25.4, JavaFX Scene Builder hides the FXML details from you, so
you can focus on defining what the GUI should contain without specifying how to gener-
ate it—this is another example of declarative programming, which we used with Java SE
lambdas in Chapter 17.
Software Engineering Observation 25.1
The FXML code is separate from the program logic that's defined in Java source code—
this separation of the interface (the GUI) from the implementation (the Java code) makes
it easier to debug, modify and maintain JavaFX GUI apps.
25.3 JavaFX App Window Structure
A JavaFX app window consists of several parts (Fig. 25.1) that you'll use in Sections 25.4-
25.5:
The window is known as the stage
The root node of this scene's scene
graph is a layout container that
arranges the other nodes
Each of the JavaFX
components in this GUI is a
node in the scene graph
The stage's scene contains
a scene graph of nodes
Fig. 25.1 | JavaFX app window parts.
The window in which a JavaFX app's GUI is displayed is known as the stage and
is an instance of class Stage (package javafx.stage ).
The stage contains one active scene that defines the GUI as a scene graph —a tree
data structure of an app's visual elements, such as GUI controls, shapes, images, vid-
eo, text and more. The scene is an instance of class Scene (package javafx.scene ).
Each visual element in the scene graph is a node —an instance of a subclass of
Node (package javafx.scene ), which defines common attributes and behaviors
for all nodes in the scene graph. With the exception of the first node in the scene
graph—known as the root node —each node has one parent. Nodes can have
transforms (e.g., moving, rotating, scaling and skewing), opacity (which controls
whether a node is transparent, partially transparent or opaque), effects (e.g., drop
shadows, blurs, reflection and lighting) and more that we'll introduce in online
Chapter 26.
 
 
Search WWH ::




Custom Search