12 JavaFX Graphical User
Interfaces: Part 1
Objectives
In this chapter you’ll:
Build JavaFX GUIs and handle
events generated by user
Self-Review Exercises 2
Self-Review Exercises
12.1 Fill in the blanks in each of the following statements:
a) A(n) can display text and accept text input from the user.
b) Use a(n) to arrange GUI components into cells in a rectangular grid.
c) JavaFX Scene Builder Document window’s section shows the structure of the
GUI and allows you to select and reorganize controls.
d) You implement interface to respond to events when the user moves a Slid-
er’s thumb.
e) A(n) represents the app’s window.
f) The method is called by the FXMLLoader before the GUI is displayed.
g) The contents of a scene are placed in its .
h) The elements in the scene graph are called .
i) allows you to build JavaFX GUIs using drag-and-drop techniques.
j) A(n) file contains the description of a JavaFX GUI.
12.2 State whether each of the following is true or false. If false, explain why.
a) You must create JavaFX GUIs by hand coding them in Java.
b) The layout VBox arranges components vertically in a scene.
c) To right align controls in a GridPane column, set its Alignment property to RIGHT.
d) The FXMLLoader initializes the controller’s @FXML instance variables.
e) You override class Application’s launch method to display a JavaFX app’s stage.
f) The control that the user is interacting with “has the focus.”
g) By default, a Slider allows you to select values from 0 to 255.
i) Every concrete Application subclass must directly or indirectly override method start.
Exercises
NOTE: Solutions to the programming exercises are located in the ch12solutions folder.
Each exercise has its own folder named ex12_## where ## is a two-digit number representing
the exercise number. For example, Exercise 12.3’s solution is located in the folder ex02_03.
© 2018 Pearson Education, Inc., 330 Hudson Street, NY NY 10013. All rights reserved.