Deck 12: Java-Fx: Gui Programming and Basic Controls
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/42
Play
Full screen (f)
Deck 12: 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
To add padding to an HBox you can call the __________ method.
A) HBoxPadding
B) SetHBoxPadding
C) setPadding
D) setHboxPad
A) HBoxPadding
B) SetHBoxPadding
C) setPadding
D) setHboxPad
C
3
A(n) __________ is an action that takes place in an application, such as the clicking of a button.
A) instance
B) effect
C) case
D) event
A) instance
B) effect
C) case
D) event
D
4
Programs that operate in a GUI environment must be __________.
A) event driven
B) in color
C) dialog boxes
D) layout managers
A) event driven
B) in color
C) dialog boxes
D) layout managers
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
5
Layout containers provide methods for fine-tuning the way controls are arranged.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
6
To display an image in a JavaFX application, you use either the Image or ImageView class.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
7
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.
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.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
8
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 42 flashcards in this deck.
Unlock Deck
k this deck
9
A GUI program automatically stops executing when the end of the main method is reached.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
10
When a splash screen is displayed, the application does not load and execute until the user clicks the splash screen image with the mouse.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
11
For this question, assume myView references an ImageView object. In order to preserve the image's aspect ratio (so it does not appear stretched or distorted), you should use which of the following?
A) myView.setPreserveRatio(false);
B) myView.setPreserveRatio(true);
C) myView.setPreserveRatio();
D) Either (a) or (c) would work.
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 42 flashcards in this deck.
Unlock Deck
k this deck
12
The BorderPane container always displays its content in five regions which are top, bottom, left, right, and center and each region must be used.
Unlock Deck
Unlock for access to all 42 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 for a user to interact with a computer.
A) command line
B) console interface
C) GUI
D) All of these are ways for a user to interact with a computer.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
14
The HBox object's setPadding method takes a(n) __________as its argument.
A) Insets method
B) Insets object
C) boolean
D) integer
A) Insets method
B) Insets object
C) boolean
D) integer
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
15
The __________ layout container arranges its contents with columns and rows.
A) GridLayout
B) GridPane
C) Grid
D) CellManager
A) GridLayout
B) GridPane
C) Grid
D) CellManager
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
16
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
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 42 flashcards in this deck.
Unlock Deck
k this deck
17
To preserve an image's aspect ratio you can use the ImageView class's PreserveAspectRatio method.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
18
The command line interface is an event-driven interface.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
19
The Pos type must be imported from the javafx.geometry package.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
20
An event object is created when an event takes place.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
21
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
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 42 flashcards in this deck.
Unlock Deck
k this deck
22
The __________ layout container arranges the contents into cells, similar to a spreadsheet.
A) GRID
B) GridPane
C) GridPaneObj
D) CellPane
A) GRID
B) GridPane
C) GridPaneObj
D) CellPane
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
23
What method do you call to register an event handler with a Button control?
A) setAction
B) onClickAction
C) setOnClick
D) setOnAction
A) setAction
B) onClickAction
C) setOnClick
D) setOnAction
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
24
The process of connecting an event handler object to a control is called __________ the event handler.
A) passing
B) registering
C) applying
D) rendering
A) passing
B) registering
C) applying
D) rendering
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
25
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
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 42 flashcards in this deck.
Unlock Deck
k this deck
26
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);
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 42 flashcards in this deck.
Unlock Deck
k this deck
27
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));
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 42 flashcards in this deck.
Unlock Deck
k this deck
28
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;
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 42 flashcards in this deck.
Unlock Deck
k this deck
29
The Application class's __________ method is the main entry point for a JavaFX application.
A) start
B) init
C) addWindow
D) mainFX
A) start
B) init
C) addWindow
D) mainFX
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
30
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
A) top and bottom
B) center
C) above and below center
D) left and right
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
31
Select all that apply. Which of the following file types are supported by the Image class?
A) BMP
B) JPEG
C) GIF
D) PNG
A) BMP
B) JPEG
C) GIF
D) PNG
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
32
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.
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 42 flashcards in this deck.
Unlock Deck
k this deck
33
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.
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 42 flashcards in this deck.
Unlock Deck
k this deck
34
When an event takes place, the control responsible for the event creates an event __________.
A) source
B) object
C) handler
D) firing
A) source
B) object
C) handler
D) firing
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
35
What does the following statement do? Image puppy = new Image("file:C:\\images\terrier. jpg");
A) It creates an instance of the ImageView class with the terrier. jpg file passed to the constructor.
B) It loads an image named "images\terrier. jpg" and stores the image in the Image variable.
C) It loads an image file named terrier. jpg 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.
A) It creates an instance of the ImageView class with the terrier. jpg file passed to the constructor.
B) It loads an image named "images\terrier. jpg" and stores the image in the Image variable.
C) It loads an image file named terrier. jpg 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 42 flashcards in this deck.
Unlock Deck
k this deck
36
An action that takes place while a program is running is a(n) __________.
A) event source
B) event handler
C) event
D) event object
A) event source
B) event handler
C) event
D) event object
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
37
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;
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 42 flashcards in this deck.
Unlock Deck
k this deck
38
To retrieve text that a user has typed into a TextField control, you call the __________ method.
A) inputText
B) getInput
C) getText
D) getInputText
A) inputText
B) getInput
C) getText
D) getInputText
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
39
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)
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 42 flashcards in this deck.
Unlock Deck
k this deck
40
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
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 42 flashcards in this deck.
Unlock Deck
k this deck
41
Select all that apply. It may be possible to simplify event handler code by using which of the following?
A) nested classes
B) anonymous inner classes
C) lambda expressions
D) listener expressions
A) nested classes
B) anonymous inner classes
C) lambda expressions
D) listener expressions
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
42
Select all that apply. Which of the following are nodes that can be used in a scene graph?
A) tree node
B) root node
C) leaf node
D) branch node
A) tree node
B) root node
C) leaf node
D) branch node
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck