Deck 11: Java-Fx: Gui Programming and Basic Controls

Full screen (f)
exit full mode
Question
An event handler class will not be executed unless it has been registered with the correct control.
Use Space or
up arrow
down arrow
to flip the card.
Question
One important difference between the command line interface and a GUI interface is that

A) in command line the background color of the monitor will always be black but in a GUI it can be any color
B) in a GUI environment the user determines the order in which things happen while the user has no control over the order or events in a command line interface
C) users must type information in a command line interface but, when using a GUI, typing is never required
D) All of these are important differences.
Question
The BorderPane container always displays its content in five regions which are top, bottom, left, right, and center and each region must be used.
Question
To display an image in a JavaFX application you must

A) include either the Image or the ImageView class
B) include both the setImage and the ViewImage classes
C) include both the Image and the ImageView classes
D) include either the setImage or the ViewImage class
Question
The command line interface is an event-driven interface.
Question
In order to leave 15 pixels of space in an HBox container, use which of the following statements?

A) myhbox = setPadding(15);
B) myhbox.setPadding(15);
C) myhbox.setPadding.Insets(15);
D) myhbox.setPadding(new Insets(15));
Question
To display an image in a JavaFX application, you use either the Image or ImageView class.
Question
The Application class's __________ method is the main entry point for a JavaFX application.

A) start
B) init
C) addWindow
D) mainFX
Question
The "preferred size" of a scene is usually the whole size of the user's monitor.
Question
The foundation of a GUI application is the

A) Stage object
B) start method
C) Application class
D) Scene object
Question
When programming in JavaFX, you should think of the GUI objects as nodes in a tree-like hierarchical structure known as a scene graph.
Question
The __________ layout container arranges the contents into cells, similar to a spreadsheet.

A) GRID
B) GridPane
C) GridPaneObj
D) CellPane
Question
Which of the following is not a way a user can interact with a computer?

A) command line
B) console interface
C) GUI
D) All of these are ways a user can interact with a computer.
Question
An event object is created when an event takes place.
Question
Padding is space that appears around the inside edges of a container.
Question
To change the alignment of an HBox you call the

A) setAlignment method
B) Alignment method
C) PreferredSize method
D) Pos method
Question
In a JavaFX application, you are limited to a single layout container since layout containers cannot be nested.
Question
All JavaFX applicatons must extend the Application class.
Question
In order to preserve an image's aspect ratio (so it does not appear stretched or distorted), you should use which of the following? Assume myView references an ImageView object.

A) myView.setPreserveRatio(false);
B) myView.setPreserveRatio(true);
C) myView.setPreserveRatio();
D) Either (a) or (c) would work.
Question
In memory, GUI objects in a __________ are organized as __________ in a tree-like hierarchical data structure.

A) node, scenes
B) scene graph, nodes
C) scene, nodes
D) scene graph, methods
Question
Which of the following import statements is required in order to create a BorderPane layout container?

A) import javafx.scene.layout.Box;
B) import javafx.scene.layout;
C) import javafx.layout.scene.BorderPane;
D) import javafx.scene.layout.BorderPane;
Question
Select all that apply. Which of the following are regions where content can be displayed in the BorderPane layout container?

A) top and bottom
B) center
C) above and below center
D) left and right
Question
To create a TextField control, you use the __________ class which is in the __________ package.

A) TextField, javafx.text.control
B) TextField, javafx.scene.control
C) TextBox, javafx.scene.control
D) TextField, javafx.textfield
Question
Select all that apply. Which of the following are operations that can be performed by the launch method?

A) creating a Stage object
B) calling the start method
C) calling the Application constructor
D) calling an event handler
Question
Select all that apply. Given the statement shown below, which of the following statements are true? Scene scene = new Scene(hbox, 100, 500);

A) The width of the scene will be 100 pixels.
B) The height of the scene will be 100 pixels.
C) A Scene object named scene will be created.
D) The root node is hbox.
Question
Select all that apply. Which of the following are constructors of the BorderPane class?

A) BorderPane()
B) BorderPane(top, bottom)
C) BorderPane(center)
D) BorderPane(left, right)
E) BorderPane(center, top, right, bottom, left)
Question
Select all that apply. Which of the following file types are supported by the Image class?

A) BMP
B) JPEG
C) GIF
D) PNG
Question
Which of the following statements correctly adds a label to the first row and second column of a GridPane object?

A) gridpane.add(myLabel, 1, 2);
B) gridpane.add(myLabel, 2, 1);
C) gridpane.add(myLabel, 0, 1);
D) gridpane.add(myLabel, 1, 0);
Question
Assuming three ImageView objects named puppy, kitten, and bunny have been created, what does the following statement do? HBox hbox = new HBox(5, puppy, kitten, bunny);

A) The number 5 refers to the number of ImageView objects so there will be two empty spots for two more ImageView objects.
B) There will be five pixels of space between the controls horizontally in the container.
C) The controls will be displayed vertically with five pixels between them.
D) The statement does nothing; it contains an error.
Question
The process of connecting an event handler object to a control is called __________ the event handler.

A) passing
B) registering
C) applying
D) rendering
Question
Which of the following import statements is required in order to write an event handler class?

A) import javafx.event.EventHandler;
B) import javafx.event.ActionEvent;
C) import javafx.EventHandler;
D) import javafx.EventHandler.event;
Question
If you set a scene's size to a width and height that is smaller than the width and height of the image to be displayed,

A) only part of the image will be displayed
B) the image will only occupy part of the window
C) the scene will automatically be resized to fit the image
D) the image will automatically be resized to fit the window
Question
An action that takes place while a program is running is a(n)

A) event source
B) event handler
C) event
D) event object
Question
Select all that apply. Which of the following nodes are allowed in a scene graph?

A) Root
B) Button
C) Leaf
D) Branch
Question
If a BorderPane region does not contain anything,

A) the region will appear gray by default
B) the region will not appear in the GUI
C) an error will occur
D) content from an adjacent region will be duplicated to appear in the empty region
Question
Which package contains the Insets class?

A) javafx.scene
B) javafx.layout
C) javafx.Insets
D) javafx.geometry
Question
What does the following statement do? Image puppy = new Image("file:C:\\images\terrier.j p g ");

A) It creates an instance of the ImageView class with the terrier. J p g file passed to the constructor.
B) It loads an image named "images\terrier.j p g " and stores the image in the Image variable.
C) It loads an image file named terrier. j p g which is found in the images folder on the user's C-drive.
D) Nothing; it is not possible to include a path to a file when using the Image class.
Question
When an event takes place, the control responsible for the event creates an event __________.

A) source
B) object
C) handler
D) firing
Question
To retrieve text that a user has typed into a TextField control, you call the __________ method.

A) inputText
B) getInput
C) getText
D) getInputText
Question
What method do you call to register an event handler with a Button control?

A) setAction
B) onClickAction
C) setOnClick
D) setOnAction
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/40
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 11: Java-Fx: Gui Programming and Basic Controls
1
An event handler class will not be executed unless it has been registered with the correct control.
True
2
One important difference between the command line interface and a GUI interface is that

A) in command line the background color of the monitor will always be black but in a GUI it can be any color
B) in a GUI environment the user determines the order in which things happen while the user has no control over the order or events in a command line interface
C) users must type information in a command line interface but, when using a GUI, typing is never required
D) All of these are important differences.
B
3
The BorderPane container always displays its content in five regions which are top, bottom, left, right, and center and each region must be used.
False
4
To display an image in a JavaFX application you must

A) include either the Image or the ImageView class
B) include both the setImage and the ViewImage classes
C) include both the Image and the ImageView classes
D) include either the setImage or the ViewImage class
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
5
The command line interface is an event-driven interface.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
6
In order to leave 15 pixels of space in an HBox container, use which of the following statements?

A) myhbox = setPadding(15);
B) myhbox.setPadding(15);
C) myhbox.setPadding.Insets(15);
D) myhbox.setPadding(new Insets(15));
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
7
To display an image in a JavaFX application, you use either the Image or ImageView class.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
8
The Application class's __________ method is the main entry point for a JavaFX application.

A) start
B) init
C) addWindow
D) mainFX
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
9
The "preferred size" of a scene is usually the whole size of the user's monitor.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
10
The foundation of a GUI application is the

A) Stage object
B) start method
C) Application class
D) Scene object
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
11
When programming in JavaFX, you should think of the GUI objects as nodes in a tree-like hierarchical structure known as a scene graph.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
12
The __________ layout container arranges the contents into cells, similar to a spreadsheet.

A) GRID
B) GridPane
C) GridPaneObj
D) CellPane
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
13
Which of the following is not a way a user can interact with a computer?

A) command line
B) console interface
C) GUI
D) All of these are ways a user can interact with a computer.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
14
An event object is created when an event takes place.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
15
Padding is space that appears around the inside edges of a container.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
16
To change the alignment of an HBox you call the

A) setAlignment method
B) Alignment method
C) PreferredSize method
D) Pos method
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
17
In a JavaFX application, you are limited to a single layout container since layout containers cannot be nested.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
18
All JavaFX applicatons must extend the Application class.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
19
In order to preserve an image's aspect ratio (so it does not appear stretched or distorted), you should use which of the following? Assume myView references an ImageView object.

A) myView.setPreserveRatio(false);
B) myView.setPreserveRatio(true);
C) myView.setPreserveRatio();
D) Either (a) or (c) would work.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
20
In memory, GUI objects in a __________ are organized as __________ in a tree-like hierarchical data structure.

A) node, scenes
B) scene graph, nodes
C) scene, nodes
D) scene graph, methods
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
21
Which of the following import statements is required in order to create a BorderPane layout container?

A) import javafx.scene.layout.Box;
B) import javafx.scene.layout;
C) import javafx.layout.scene.BorderPane;
D) import javafx.scene.layout.BorderPane;
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
22
Select all that apply. Which of the following are regions where content can be displayed in the BorderPane layout container?

A) top and bottom
B) center
C) above and below center
D) left and right
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
23
To create a TextField control, you use the __________ class which is in the __________ package.

A) TextField, javafx.text.control
B) TextField, javafx.scene.control
C) TextBox, javafx.scene.control
D) TextField, javafx.textfield
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
24
Select all that apply. Which of the following are operations that can be performed by the launch method?

A) creating a Stage object
B) calling the start method
C) calling the Application constructor
D) calling an event handler
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
25
Select all that apply. Given the statement shown below, which of the following statements are true? Scene scene = new Scene(hbox, 100, 500);

A) The width of the scene will be 100 pixels.
B) The height of the scene will be 100 pixels.
C) A Scene object named scene will be created.
D) The root node is hbox.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
26
Select all that apply. Which of the following are constructors of the BorderPane class?

A) BorderPane()
B) BorderPane(top, bottom)
C) BorderPane(center)
D) BorderPane(left, right)
E) BorderPane(center, top, right, bottom, left)
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
27
Select all that apply. Which of the following file types are supported by the Image class?

A) BMP
B) JPEG
C) GIF
D) PNG
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
28
Which of the following statements correctly adds a label to the first row and second column of a GridPane object?

A) gridpane.add(myLabel, 1, 2);
B) gridpane.add(myLabel, 2, 1);
C) gridpane.add(myLabel, 0, 1);
D) gridpane.add(myLabel, 1, 0);
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
29
Assuming three ImageView objects named puppy, kitten, and bunny have been created, what does the following statement do? HBox hbox = new HBox(5, puppy, kitten, bunny);

A) The number 5 refers to the number of ImageView objects so there will be two empty spots for two more ImageView objects.
B) There will be five pixels of space between the controls horizontally in the container.
C) The controls will be displayed vertically with five pixels between them.
D) The statement does nothing; it contains an error.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
30
The process of connecting an event handler object to a control is called __________ the event handler.

A) passing
B) registering
C) applying
D) rendering
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
31
Which of the following import statements is required in order to write an event handler class?

A) import javafx.event.EventHandler;
B) import javafx.event.ActionEvent;
C) import javafx.EventHandler;
D) import javafx.EventHandler.event;
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
32
If you set a scene's size to a width and height that is smaller than the width and height of the image to be displayed,

A) only part of the image will be displayed
B) the image will only occupy part of the window
C) the scene will automatically be resized to fit the image
D) the image will automatically be resized to fit the window
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
33
An action that takes place while a program is running is a(n)

A) event source
B) event handler
C) event
D) event object
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
34
Select all that apply. Which of the following nodes are allowed in a scene graph?

A) Root
B) Button
C) Leaf
D) Branch
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
35
If a BorderPane region does not contain anything,

A) the region will appear gray by default
B) the region will not appear in the GUI
C) an error will occur
D) content from an adjacent region will be duplicated to appear in the empty region
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
36
Which package contains the Insets class?

A) javafx.scene
B) javafx.layout
C) javafx.Insets
D) javafx.geometry
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
37
What does the following statement do? Image puppy = new Image("file:C:\\images\terrier.j p g ");

A) It creates an instance of the ImageView class with the terrier. J p g file passed to the constructor.
B) It loads an image named "images\terrier.j p g " and stores the image in the Image variable.
C) It loads an image file named terrier. j p g which is found in the images folder on the user's C-drive.
D) Nothing; it is not possible to include a path to a file when using the Image class.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
38
When an event takes place, the control responsible for the event creates an event __________.

A) source
B) object
C) handler
D) firing
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
39
To retrieve text that a user has typed into a TextField control, you call the __________ method.

A) inputText
B) getInput
C) getText
D) getInputText
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
40
What method do you call to register an event handler with a Button control?

A) setAction
B) onClickAction
C) setOnClick
D) setOnAction
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 40 flashcards in this deck.