Chapter 16 JavaFX UI Controls and Multimedia

Section 16.2 Labeled and Label
1. To create a label with the specified text, use __________.
a. new Labelled();
b. new Label();
c. new Labelled(text);
d. new Label(text);
Key:d

#
2. To set a red color for the text in the label lbl, use _________.
a.    lbl.setFill(Color.red);
b.    lbl.setTextFill(Color.red);
c.    lbl.setFill(Color.RED);
d.    lbl.setTextFill(Color.RED);
Key:d

#
3. __________ are properties in Labelled.
a.    alignment
b.    contentDisplay
c.    graphic
d.    text
e.    underline
Key:abcde

#
4. To set the node to the right of the text in a label lbl, use _______.
a.    lbl.setContentDisplay(ContentDisplay.TOP);
b.    lbl.setContentDisplay(ContentDisplay.BOTTOM);
c.    lbl.setContentDisplay(ContentDisplay.LEFT);
d.    lbl.setContentDisplay(ContentDisplay.RIGHT);
Key:d

#
Section 16.3 Button
5.    __________ is a superclass for Button.
a.    Label
b.    Labelled
c.    ButtonBase
d.    Control
e.    Node
Key:bcde
ButtonBase是Button的父类,Labelled是ButtonBase的父类,Control是Labelled的父类,Parent是Control的父类,Node是Parent的父类
#
6.    __________ is a superclass for Label.
a.    Scene
b.    Labelled
c.    ButtonBase
d.    Control
e.    Node
Key:bde

#
7.    The setOnAction method is defined in _________.
a.    Label
b.    Labelled
c.    Node
d.    ButtonBase
e.    Button
Key:d

#
8.    Analyze the following code:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.stage.Stage; public class Test extends Application {
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
HBox pane = new HBox(5);
Image usIcon = new Image("http://www.cs.armstrong.edu/liang/image/usIcon.gif");
Button bt1 = new Button("Button1", new ImageView(usIcon));
Button bt2 = new Button("Button2", new ImageView(usIcon));
pane.getChildren().addAll(bt1, bt2); Scene scene = new Scene(pane, 200, 250);
primaryStage.setTitle("Test"); // Set the stage title
primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage
} /**
* The main method is only needed for the IDE with limited JavaFX
* support. Not needed for running from the command line.
*/
public static void main(String[] args) {
launch(args);
}
}

a. Two buttons displayed with the same icon.
b. Only bt2 displays the icon and bt1 does not display the icon.
c. Only bt1 displays the icon and bt2 does not display the icon.
d. Two buttons displayed with different icons.
Key:a Since images can be shared, both bt1 and bt2 display the same icon.

#
9.    Analyze the following code:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage; public class Test extends Application {
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
StackPane pane = new StackPane();
Button bt1 = new Button("Java");
Button bt2 = new Button("Java");
Button bt3 = new Button("Java");
Button bt4 = new Button("Java");
pane.getChildren().addAll(bt1, bt2, bt3, bt4); Scene scene = new Scene(pane, 200, 250);
primaryStage.setTitle("Test"); // Set the stage title
primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage
} /**
* The main method is only needed for the IDE with limited JavaFX
* support. Not needed for running from the command line.
*/
public static void main(String[] args) {
launch(args);
}
}

a. One button is displayed with the text "Java".
b. Two buttons are displayed with the same text "Java".
c. Three buttons are displayed with the same text "Java".
d. Four buttons are displayed with the same text "Java".
Key:

a Because you are using a StackPane.

#
10.    Analyze the following code:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.Pane;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage; public class Test extends Application {
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
Pane pane = new FlowPane();
Button bt1 = new Button("Java");
Button bt2 = new Button("Java");
Button bt3 = new Button("Java");
Button bt4 = new Button("Java");
pane.getChildren().addAll(bt1, bt2, bt3, bt4); Scene scene = new Scene(pane, 200, 250);
primaryStage.setTitle("Test"); // Set the stage title
primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage
} /**
* The main method is only needed for the IDE with limited JavaFX
* support. Not needed for running from the command line.
*/
public static void main(String[] args) {
launch(args);
}
}

a. One button is displayed with the text "Java".
b. Two buttons are displayed with the same text "Java".
c. Three buttons are displayed with the same text "Java".
d. Four buttons are displayed with the same text "Java".
Key:d
注意这里是FlowPane流式布局
#
Section 16.4 CheckBox
11. _________ checks whether the CheckBox chk is selected.
a. chk.getSelected()
b. chk.selected()
c. chk.isSelected().
d. chk.select()
Key:c

#
12. Which of the following statements are true?
a. CheckBox inherits from ButtonBase.
b. CheckBox inherits from Button.
c. CheckBox inherits from Labelled.
d. CheckBox inherits from Control.
e. CheckBox inherits from Node.
Key:acde
CheckBox inherits from Button.
#
Section 16.5 RadioButton
13. Which of the following statements are true?
a. RadioButton inherits from ButtonBase.
b. RadioButton inherits from Button.
c. RadioButton inherits from Labelled.
d. RadioButton inherits from Control.
e. RadioButton inherits from Node.
Key:acde

#
14. _________ checks whether the RadioButton rb is selected.
a. rb.getSelected()
b. rb.selected()
c. rb.isSelected().
d. rb.select()
Key:c

#
15. Analyze the following code:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.Pane;
import javafx.stage.Stage; public class Test extends Application {
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
Pane pane = new FlowPane(); ToggleGroup group = new ToggleGroup();
RadioButton rb1 = new RadioButton("Java");
RadioButton rb2 = new RadioButton("C++");
pane.getChildren().addAll(rb1, rb2); Scene scene = new Scene(pane, 200, 250);
primaryStage.setTitle("Test"); // Set the stage title
primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage
} /**
* The main method is only needed for the IDE with limited JavaFX
* support. Not needed for running from the command line.
*/
public static void main(String[] args) {
launch(args);
}
}

a. The program displays two radio buttons. The two radio buttons are grouped.
b. The program displays one radio button with text Java.
c. The program displays two radio buttons. The two radio buttons are not grouped.
d. The program displays one radio button with text C++.
Key:c To group the two use rb1.setToggleGroup(group); rb2.setToggleGroup(group);

#
Section 16.6 TextField
16. Which of the following statements are true?
a. TextField inherits from TextInputControl.
b. TextField inherits from ButtonBase.
c. TextField inherits from Labelled.
d. TextField inherits from Control.
e. TextField inherits from Node.
Key:ade
TextField 是TextInputControl的子类,TextInputControl是Control的子类
#
17. The properties ___________ can be used in a TextField.
a. text
b. editable
c. alignment
d. prefColumnCount
e. onAction
Key:abcde

#
18.    Which of the following statements are true?
a.    You can specify a horizontal text alignment in a text field.
b.    You can specify the number of columns in a text field.
c.    You can disable editing on a text field.
d.    You can create a text field with a specified text.
Key:abcd

#
19.    The method __________ gets the contents of the text field tf.
a.    tf.getText(s)
b.    tf.getText()
c.    tf.getString()
d.    tf.findString()
Key:b

#
20. Which of the following statements are true?
a. PasswordField inherits from TextInputControl.
b. PasswordField inherits from TextField.
c. PasswordField inherits from Labelled.
d. PasswordField inherits from Control.
e. PasswordField inherits from Node.
Key:abde

#
Section 16.7 TextArea
21.    The method __________ appends a string s into the text area ta.
a.    ta.setText(s)
b.    ta.appendText(s)
c.    ta.append(s)
d.    ta.insertText(s)
Key:b

#
22.    Which of the following statements are true?
a.    You can specify a horizontal text alignment in a text area.
b.    You can specify the number of columns in a text area.
c.    You can disable editing on a text area.
d.    You can create a text field with a specified text area.
e.    You can specify the number of rows in a text area.
Key:bcde

#
23.    To wrap a line in a text area ta, invoke ____________.
a.    ta.setLineWrap(false)
b.    ta.setLineWrap(true)
c.    ta.WrapLine()
d.    ta.wrapText()
e.    ta.setWrapText(true)
Key:e

#
24.    To wrap a line in a text area jta on words, invoke ____________.
a.    jta.setWrapStyleWord(false)
b.    jta.setWrapStyleWord(true)
c.    jta.wrapStyleWord()
d.    jta.wrapWord()
Key:b

#
25. Which of the following statements are true?
a. TextArea inherits from TextInputControl.
b. TextArea inherits from TextField.
c. TextArea inherits from Labelled.
d. TextArea inherits from Control.
e. TextArea inherits from Node.
Key:ade

#
Section 16.8 ComboBox
26.    How many items can be added into a ComboBox object?
a.    0
b.    1
c.    2
d.    Unlimited
Key:d

#
27.    How many items can be selected from a ComboBox at a time?
a.    0
b.    1
c.    2
d.    Unlimited
Key:b

#
28.    _______________ returns the selected item on a ComboBox cbo.
a.    cbo.getSelectedIndex()
b.    cbo.getSelectedItem()
c.    cbo.getSelectedIndices()
d.    cbo.getSelectedItems()
e.    cbo.getValue()
Key:e

#
29.    The method __________ adds an item s into a ComboBox cbo.
a.    cbo.add(s)
b.    cbo.addChoice(s)
c.    cbo.addItem(s)
d.    cbo.addObject(s)
e.    cbo.getItems().add(s)
Key:e

#
30. Which of the following statements are true?
a. ComboBox inherits from ComboBoxBase.
b. ComboBox inherits from ButtonBase.
c. ComboBox inherits from Labelled.
d. ComboBox inherits from Control.
e. ComboBox inherits from Node.
Key:ade

#
31. You can use the _________ properties in a ComboBox.
a.    value
b.    editable
c. onAction
d. items
e. visibleRowCount
Key:abcde

#
Section 16.9 Lists
32.  ____________ are properties for a ListView.
a. items
b. orientation
c. selectionModel
d. visibleRowCount
e. onAction
Key:abc

#
33. Which of the following statements are true?
a. ListView inherits from ComboBoxBase.
b. ListView inherits from ButtonBase.
c. ListView inherits from Labelled.
d. ListView inherits from Control.
e. ListView inherits from Node.
Key:de

#
34. The statement for registering a listener for processing list view item change is ___________.
a. lv.getItems().addListener(e -> {processStatements});
b. lv.addListener(e -> {processStatements});
c. lv.getSelectionModel().selectedItemProperty().addListener(e -> {processStatements});
d. lv.getSelectionModel().addListener(e -> {processStatements});
Key:c

#
Section 16.10 ScrollBar
35.    __________ are properties of ScrollBar.
a.    value
b.    min
c.    max
d.    orientation
e.    visibleAmount
Key:abcde

#
36. The statement for registering a listener for processing scroll bar value change is ___________.
a. sb.addListener(e -> {processStatements});
b. sb.getValue().addListener(e -> {processStatements});
c. sb.valueProperty().addListener(e -> {processStatements});
d. sb.getItems().addListener(e -> {processStatements});
Key:c

#
Section 16.11 Slider
37.    __________ are properties of Slider.
a.    value
b.    min
c.    max
d.    orientation
e.    visibleAmount
Key:abcde

#
38. The statement for registering a listener for processing slider change is ___________.
a. sl.addListener(e -> {processStatements});
b. sl.getValue().addListener(e -> {processStatements});
c. sl.valueProperty().addListener(e -> {processStatements});
d. sl.getItems().addListener(e -> {processStatements});
Key:c

#
Section 16.13 Video and Audio
39.    Which of the following statements are true?
a.    A Media can be shared by multiple MediaPlayer.
b.    A MediaPlayer can be shared by multiple MediaView.
c.    A MediaView can be placed into multiple Pane.
d.    A Media can be downloaded from a URL.
Key:abd

#
40.    You can use the methods _________ to control a MediaPlayer.
a.    start().
b.    stop().
c.    pause().
d.    play().
Key:cd

#
41.    You can use the properties _________ to control a MediaPlayer.
a.    autoPlay
b.    currentCount
c.    cycleCount
d.    mute
e. volume
Key:abcde

#
42.    You can use the properties _________ in a MediaView.
a.    x
b.    y
c.    mediaPlayer
d.    fitWidth
e. fitHeight
Key:abcde

Java题库——Chapter16 JavaFX UI组件和多媒体的更多相关文章

  1. Java题库——Chapter14 JavaFX基础

    Chapter 14 JavaFX Basics Section 14.2 JavaFX vs Swing and AWT1. Why is JavaFX preferred?a. JavaFX is ...

  2. Java题库——Chapter13抽象类和接口

    )What is the output of running class Test? public class Test { public static void main(String[ ] arg ...

  3. Java题库——Chapter8 对象和类

    1)________ represents an entity(实体) in the real world that can be distinctly identified. 1) _______ ...

  4. JAVA题库01

    说出一些常用的类,包,接口,请各举5个 常用的类:BufferedReader  BufferedWriter  FileReader  FileWirter  String Integer java ...

  5. Java题库——Chapter17 二进制I/0

    Introduction to Java Programming 的最后一章,完结撒花!Chapter 17 Binary I/O Section 17.2 How is I/O Handled in ...

  6. Java题库——Chapter15 事件驱动编程和动画

    Chapter 15 Event-Driven Programming and Animations Section 15.2 Events and Event Sources1.    A Java ...

  7. Java题库——Chapter12 异常处理和文本IO

    异常处理 1)What is displayed on the console when running the following program? class Test { public stat ...

  8. Java题库——Chapter11 继承和多态

    1)Analyze the following code: public class Test { public static void main(String[ ] args) { B b = ne ...

  9. Java题库——Chapter10 面向对象思考

    1)You can declare two variables with the same name in ________. 1) _______ A)a method one as a forma ...

随机推荐

  1. c语言l博客作业09

    问题 答案 这个作业属于那个课程 C语言程序设计II 这个作业要求在哪里 https://edu.cnblogs.com/campus/zswxy/CST2019-2/homework/8655 我在 ...

  2. redis与memcached区别

    不同点: (1) redis中并不是所有数据在有效期内只能常驻内存的(如果需要,可定期同步持久化到磁盘),这是和memcached相比一个最大的区别(memcached中的数据在有效期内是以键值对的形 ...

  3. PHP fsockopen受服务器KeepAlive影响的解决

    在开发过程中常常遇到这样的需求,模拟浏览器访问某接口,并获取返回数据.我们比较常使用的方法是fsockopen与接口建立连接,然后发出指令,然后通过fgets接受返回值. 但是我们发现,通过PHP模拟 ...

  4. Android View 的绘制流程之 Layout 和 Draw 过程详解 (二)

    View 的绘制系列文章: Android View 的绘制流程之 Measure 过程详解 (一) Android View 绘制流程之 DecorView 与 ViewRootImpl 在上一篇  ...

  5. java前端与后端怎么选??

    想做这个行业,就应该了解职能以及技能需求,这样学习才能更高效.我知道一些刚刚入行的小伙伴不清楚前端.后端.到底指的是什么?两者直接的区别 前端开发 前端开发主要涉及网站和App,用户能够从浏览器上或A ...

  6. MyBatis开发Dao的原始Dao开发和Mapper动态代理开发

    目录 咳咳...初学者看文字(Mapper接口开发四个规范)属实有点费劲,博主我就废了点劲做了如下图,方便理解: 原始Dao开发方式 1. 编写映射文件 3.编写Dao实现类 4.编写Dao测试 Ma ...

  7. 深度研究:回归模型评价指标R2_score

    回归模型的性能的评价指标主要有:RMSE(平方根误差).MAE(平均绝对误差).MSE(平均平方误差).R2_score.但是当量纲不同时,RMSE.MAE.MSE难以衡量模型效果好坏.这就需要用到R ...

  8. BX谷 2019年最新所有人都能学会的数据分析课视频教程

    第一章 数据分析师职业概览 1-1 数据分析师的职业概览免费试学 数据分析师的"钱"景如何 什么人适合学数据分析 数据分析师的临界知识 数据分析师的主要职责 第二章 数据分析和数据 ...

  9. rails gem ransack 之模糊搜索

    gem 'ransack' eq: "等于" eq_any: "等于任意值" eq_all: "等于所有值" not_eq: "不 ...

  10. 2.成产出现 max(vachar2)取值问题

    uat 测试结果正确max(9)>max(8),结果生产出现 max(9)>max(12) 原因:字符类型,默认比较第一个字符的ASCII码. 解决方式: max(to_number(va ...