Introduction to Java Programming, Sixth Edition, Y. Daniel Liang
Chapter 29 Menus, Toolbars, Dialogs, and Internal Frames
Section 29.2 Menus
1
The method __________ places a menu bar mb into the frame f.
A.
f.setJMenu(mb)
B.
f.add(mb)
C.
f.setJMenuBar(mb)
D.
f.addBar(mb)
2
The method __________ places a menu mu into a menu bar mb.
A.
mb.add(mu)
B.
mb.addMenuItem(mu)
C.
mb.addItem(mu)
D.
None of the above.
3
The method __________ places a menu item mi into a menu mu.
A.
mu.add(mi)
B.
mu.addMenuItem(mi)
C.
mu.addItem(mi)
D.
None of the above.
4
A MenuItem object can generate __________ events.
A.
ActionEvent
B.
ItemEvent
C.
ComponentEvent
D.
ContainerEvent
5
The method __________ separates menu items in a menu mu.
A.
mu.add('-')
B.
mu.addSeparator()
C.
Either a or b
D.
None of the above.
6
A JMenuItem is a subclass of ________.
A.
JButton
B.
AbstractButton
C.
JComponent
D.
JMenu
7
A JMenu is a subclass of ________.
A.
JMenuItem
B.
AbstractButton
C.
JComponent
D.
JButton
8
A JCheckBoxMenuItem is a subclass of ________.
A.
JMenuItem
B.
AbstractButton
C.
JComponent
D.
JMenu
9
A JRadioButtonMenuItem is a subclass of ________.
A.
JMenuItem
B.
AbstractButton
C.
JComponent
D.
JMenu
10
You can set a mnemonic property on ___________.
A.
a JMenu
B.
a JMenuItem
C.
a JCheckBoxMenuItem
D.
a JRadioButtonMenuItem
11
You can set an imageIcon property on ___________.
A.
a JMenu
B.
a JMenuItem
C.
a JCheckBoxMenuItem
D.
a JRadioButtonMenuItem
12
You can add a menu item into set an imageIcon property on ___________.
A.
a JMenu
B.
a JMenuItem
C.
a JCheckBoxMenuItem
D.
a JRadioButtonMenuItem
13
Which of the following statements are true?
A.
You can add a JMenuItem to a JMenu.
B.
You can add a JMenu to a JMenuItem.
C.
You can add a JRadioButtonMenuItem to a JMenuItem.
D.
You can add a JRadioButtonMenuItem to a JMenu.
E.
You can add a JMenuItem to a JRadioButtonMenuItem.
Section 29.3 Popup Menus
14
A JPopupMenu is a subclass of ________.
A.
JMenuItem
B.
AbstractButton
C.
JComponent
D.
JMenu
15
Which of the following statements are true?
A.
You can add a JMenuItem to a JPopupMenu.
B.
You can add a JMenu to a JPopupMenu.
C.
You can add a JRadioButtonMenuItem to a JPopupMenu.
D.
You can add a JCheckBoxMenuItem to a JPopupMenu.
E.
You can add a JPopupMenu to a JMenu.
16
How do you display a JPopupMenu?
A.
Invoke the setVisible(true) from a JPopupMenu.
B.
Invoke the show() from a JPopupMenu.
C.
Invoke the show(Component, x, y) from a JPopupMenu.
D.
Add the JPopupMenu to a container.
17
_____________ is the action that causes a popup menu to be displayed.
A.
Popup trigger
B.
Popup action
C.
Popup event
D.
Popup reaction
Section 29.4 JToolBar
18
JToolBar uses _________.
A.
FlowLayout
B.
SpringLayout
C.
BoxLayout
D.
GridLayout
E.
BorderLayout
19
Which of the following statements are correct?
A.
You can add any GUI component to a JToolBar.
B.
A JToolBar is a GUI component, so it can be added to a container.
C.
A JToolBar may be floatable.
D.
YOu can set orientation of a JToolBar.
Section 29.5 Processing Actions Using the Action Interface
20
Which of the following statements are true?
A.
Action is a subinterface of ActionListener.
B.
JMenu has an add method that enables you to add an instance of ActionListener to the menu.
C.
JMenu has an add method that enables you to add an instance of Action to the menu.
D.
JToolBar has an add method that enables you to add an instance of ActionListener to the menu.
21
Which of the following statements are true?
A.
JToolBar has an add method that enables you to add an instance of ActionListener to the menu.
B.
JToolBar has an add method that enables you to add an instance of Action to the menu.
C.
JButton has an add method that enables you to add an instance of ActionListener to the menu.
D.
JButton has an add method that enables you to add an instance of Action to the menu.
E.
JButton has a constructor new JButton(Action) that enables you to add an instance of Action to the menu.
Section 29.6 JOptionPane Dialogs
22
______________ displays a message that alerts the user and waits for the user to click the OK button to close the dialog.
A.
A message dialog
B.
A confirmation dialog
C.
An input dialog
D.
An option dialog
23
____________ asks a question and requires the user to respond with an appropriate button.
A.
A message dialog
B.
A confirmation dialog
C.
An input dialog
D.
An option dialog
24
__________ is used to receive input from the user.
A.
A message dialog
B.
A confirmation dialog
C.
An input dialog
D.
An option dialog
25
___________ allows you to create custom buttons.
A.
A message dialog
B.
A confirmation dialog
C.
An input dialog
D.
An option dialog