Java How to Program, 11/e Multiple Choice Test Bank Page 1 of
9
JavaFX GUI: Part 2
13.2 Laying Out Nodes in a Scene Graph
13.2 Q1: ________ refers to the size and positioning of nodes in the sce-
ne graph.
a. Arrangement
b. Layout
c. Structure
d. Configuration
13.2 Q2: Which of the following statements is false?
a. A node’s position should be defined relative to its parent node and
the other nodes in its parent.
b. JavaFX layout panes arrange nodes in a scene graph relative to one
another, based on their sizes and positions.
c. Most JavaFX layout panes use absolute positioning—if a layout-pane
node is resized, it adjusts its childrens’ sizes and positions according-
ly, based on their properties.
d. All of the above statements are true.
13.2 Q3: Which of the following describes an AnchorPane?
a. Enables you to set the position of child nodes relative to the pane’s
edges. Resizing the pane does not alter the layout of the nodes.
b. Includes five areas—top, bottom, left, center and right—where you
can place nodes. The top and bottom regions fill its width and are ver-
tically sized to their children’s preferred heights. The left and right
regions fill its height and are horizontally sized to their children’s
preferred widths. The center area occupies all of its remaining space.
Java How to Program, 11/e Multiple Choice Test Bank Page 2 of
9
You might use the different areas for tool bars, navigation, a main
content area, etc.
c. Lays out nodes consecutively—either horizontally or vertically.
When the boundary for the pane is reached, the nodes wrap to a new
line in a horizontal pane or a new column in a vertical pane.
d. Creates a flexible grid for laying out nodes in rows and columns.
13.2 Q4: Which of the statements a, b and c is true?
a. Pane is the base class for layout panes. This can be used to position
nodes at fixed locations—known as absolute positioning.
b. StackPane Places nodes in a stack. Each new node is stacked
atop the previous node. You might use this to place text on top of im-
ages, for example.
c. TilePane A horizontal or vertical grid of equally sized tiles. Nodes
that are tiled horizontally wrap at the TilePane’s width. Nodes that
are tiled vertically wrap at the TilePane’s height.
d. All of these statements are true.
13.3 Painter App: RadioButtons, Mouse Events and Shapes
13.3.1 Technologies Overview
13.3.1 Q1: Which of the following statements is false?
a. You add multiple RadioButtons to a ToggleGroup to ensure that
many RadioButtons in a given group can be selected at a time.
b. You can specify each RadioButton’s ToggleGroup in FXML.
c. You can create a ToggleGroup in Java, then use a RadioButton’s
setToggleGroup method to specify its ToggleGroup.
d. A TitledPane displays a title at its top and is a collapsible panel
containing a layout node, which in turn contains other nodes.
© Copyright 1992–2017 by Deitel & Associates, Inc. and Pearson Education, Inc.
13.3.1 Q2: Which of the following is most closely associated with the
statement, “Occurs for a given node when a drag operation that start-
ed in a different node continues over the given node.”
a. onMouseDragEntered
b. onMouseDragExited
c. onMouseDragged
d. onMouseDragOver
13.3.1 Q3: Which of the following is most closely associated with the
statement, “Occurs for a given node when the mouse exits that node’s
bounds.”
a. onMouseDragReleased
b. onMouseExited
c. onMouseMoved
d onMouseReleased
13.3.2 Creating the Painter.xml File
(No questions.)
13.3.3 Building the GUI
13.3.3 Q1: Which of the following statements is true?
a. A VBox’s Spacing property specifies vertical spacing between its
controls.
b. Setting a control’s Max Width property to MAX_VALUE enables the
control to fill its parent node’s width.
c. A control’s On Mouse Dragged event handler (located under the
Mouse heading in the Code section) specifies what to do when the us-
er drags the mouse on the control.
d. Each of these statements is true.
Java How to Program, 11/e Multiple Choice Test Bank Page 4 of
9
13.3.5 Painter Subclass of Application
(No questions.)
13.3.5 PainterController Class
13.3.5 Q1: Which of the following statements is false?
a. ToggleGroup method getSelectedToggle returns the Toggle
that’s currently selected. Class RadioButton is one of several controls
(others are RadioButtonMenuItem and ToggleButton) that imple-
ments interface Toggle.
b. Each mouse event handler you define must provide one parameter
of type MouseEvent. When the event occurs, this parameter contains
information about the mouse event, such as its location, whether any
mouse buttons were pressed, which node the user interacted with and
more.
c. Each layout pane has a getChildren method that returns an Ob-
servableList<Node> collection containing the layout’s child nodes.
d. All JavaFX shapes inherit indirectly from class Shape in the ja-
vafx.scene package.
13.4 Color Chooser App: Property Bindings and Property Listeners
13.4.1 Technologies Overview
13.4.1 Q1: Which of the following statements is false?
a. In the RGBA color system every color is represented by its red,
green and blue color values, each ranging from 0 to 255, where 0 de-
notes no color and 255 full color.
b. The alpha value (A of RGBA)—which ranges from 0.0 to
1.0—represents a color’s opacity, with 0.0 being completely trans-
parent and 1.0 completely opaque.
c. JavaFX makes extensive use of properties. A property is defined by
creating set and get methods with specific naming conventions.
public void setHour(int hour)
public int getHour()
Java How to Program, 11/e Multiple Choice Test Bank Page 5 of
9
define a read/write property named hour. Such methods manipulate
a corresponding private instance variable that must have the same
name as the property.
d. In general, the pair of methods that define a read/write property
have the form:
public void setPropertyName(Type propertyName)
public Type getPropertyName()
13.4.1 Q2: JavaFX properties are ________—when a property’s value
changes, other objects can respond accordingly.
a. transparent
b. transferable
c. observable
d. disposable
13.4.2 Building the GUI
13.4.2 Q1: As you build a GUI, recall that it’s often easier to manipulate
layouts and controls via Scene Builder’s ________ window than di-
rectly in the stage design area.
a. Inspector
b. Document
c. Controller
d. Library
Java How to Program, 11/e Multiple Choice Test Bank Page 6 of
9
13.4.3 ColorChooser Class
(No questions.)
13.4.4 ColorChooserController Class
13.4.4 Q1: Each TextField has a text property that’s returned by its
textProperty method as a StringProperty. The StringProperty
method ________ receives an ObservableValue as an argument. When
the ObservableValue changes, the bound property is updated ac-
cordingly.
a. tie
b. join
c. attach
d. bind
13.4.4 Q2: To perform an arbitrary task when a property’s value
changes, you can register a property ________.
a. inquirer
b. follower
c. listener
d. spectator
13.5 Cover Viewer App: Data-Drivien GUIs with JavaFX Collections
13.5.1 Technologies Overview
13.5.1 Q1: Though you can individually add items to a ListView, you
can also bind a(n) ________ object to the ListView. If you make
changes to this object, its observer will automatically be notified of
those changes.
a. ListObserver
b. ObservableList
c. LIstViewObserver
d. None of the above
Java How to Program, 11/e Multiple Choice Test Bank Page 8 of
9
b. To create a custom ListView cell format, you must first define a
subclass of the ListCell that specifies how to create a ListView cell.
c. As the ListView displays items, it gets ListView cells from its cell
factory.
d. You’ll use the ListView’s setCellFactory method to replace the
default cell factory with one that returns objects of the ListCell
subclass. You override this class’s updateItem method to specify the
cells’ custom layout and contents.
Section 13.6.3 ImageTextCell Custom Cell Factory Class
13.6.3 Q1: The ListCell<Type> subclass’s ________ method creates the
custom presentation. This method is called by the ListView’s cell
factory when a ListView cell is required—that is, when the
ListView is first displayed and when ListView cells are about to
scroll onto the screen.
a. update
b. updateItem
c. newPresentation
d. None of the above.
Section 13.6.4 CoverViewerController Class
13.6.4 Q1: The argument to ListView method setCellFactory is an
implementation of interface ________ (package javafx.util). This
generic interface provides a call method that receives one argument
and returns an object of the custom ListCell<Type> subclass.
a. Call
b. getListCell
c. CallBack
d. None of the above.
Java How to Program, 11/e Multiple Choice Test Bank Page 9 of
9
Section 13.7 Additional JavaFX Capabilities
(No questions.)