Questions and Answers| Latest Update
The ____ responds to keyboard events.
a. KeyListener
b. ActionListener
c. ChangeListener
d. FocusListener ✔️✔️a. KeyListener
The JButton, JCheckBox, JComboBox, and JRadioButton components are associated with the
____ method.
a. addAdjustmentListener()
b. addChangeListener()
c. addWindowListener()
d. addItemListener() ✔️✔️d. addItemListener()
A method that executes because it is called automatically when an appropriate event occurs is
an event ____.
a. responder
b. listener
c. handler
d. source ✔️✔️c. handler
Which method do you use to change the state of a JCheckBox?
a. void setSelected(boolean)
b. boolean isSelected()
c. void setText(String)
, d. String getText() ✔️✔️a. void setSelected(boolean)
Within an implementation of the itemStateChanged() method, you can use the ____ method to
determine which object generated the event, and the getStateChange() method to determine
whether the event was a selection or a deselection.
a. getSource()
b. getEvent()
c. getItem()
d. getState() ✔️✔️c. getItem()
When you create a(n) ____, you can group several components, such as JCheckBoxes, so a user
can select only one at a time.
a. CheckGroup
b. ButtonGroup
c. OptionBox
d. OptionGroup ✔️✔️b. ButtonGroup
A ____ is a component that combines a button or an editable field and a drop-down list.
a. JCheckBox
b. JComboBox
c. JButton
d. JTextBox ✔️✔️b. JComboBox
The ____ method of JComboBox returns the maximum number of items the combo box can
display without a scroll bar.
a. getSelectedItem()
b. getItemCount()
c. getMaximumRowCount()