Deck 20: Graphical User Interfaces
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
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/75
Play
Full screen (f)
Deck 20: Graphical User Interfaces
1
In Java, each container has its own ____________________, which determines how the components are laid out.
A.container
B.layout manager
C.Swing component
D.frame manager
A.container
B.layout manager
C.Swing component
D.frame manager
layout manager
2
If a JPanel with a BorderLayout manager contains a single component that was added to the CENTER, which parts of the JPanel does the component fill?
I North
II South
III Center
IV West
V East
A.I, II and III
B.II, IV and V
C.III, IV and V
D.I, II, III, IV and V
I North
II South
III Center
IV West
V East
A.I, II and III
B.II, IV and V
C.III, IV and V
D.I, II, III, IV and V
I, II, III, IV and V
3
To create a _____ layout, you supply the number of rows and columns in the constructor, then add the components, row by row, left to right.
A.border
B.grid
C.grid bag
D.boxed
A.border
B.grid
C.grid bag
D.boxed
grid
4
A complex GUI can be created with a set of nested panels.What should determine the components that go into a single panel?
A.the type of components
B.the size of the components
C.the adjacency of the components
D.the names of the components
A.the type of components
B.the size of the components
C.the adjacency of the components
D.the names of the components
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
5
What is the default layout manager of JPanel?
A.FlowLayout
B.GridLayout
C.BoxLayout
D.GridBagLayout
A.FlowLayout
B.GridLayout
C.BoxLayout
D.GridBagLayout
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
6
Which layout manager uses a grid, but allows selected grid locations to span multiple rows or columns?
I GridBagLayout
II BorderLayout
III GridLayout
A.Only I
B.Only II
C.Only III
D.I and III
I GridBagLayout
II BorderLayout
III GridLayout
A.Only I
B.Only II
C.Only III
D.I and III
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
7
Which layout manager places objects left-to-right, row by row into a fixed set of rows and columns?
A.FlowLayout
B.BorderLayout
C.BoxLayout
D.GridLayout
A.FlowLayout
B.BorderLayout
C.BoxLayout
D.GridLayout
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
8
Which layout manager constructor call would be best-suited to create a telephone keypad GUI which has three rows of three keys that are labeled 1,2,3; 4,5,6; and 7,8,9; respectively, as well as a fourth row of three keys labeled *, 0, #?
A.new GridLayout(3, 4)
B.new GridLayout(4, 3)
C.new FlowLayout(4, 3)
D.new BorderLayout(3, 4)
A.new GridLayout(3, 4)
B.new GridLayout(4, 3)
C.new FlowLayout(4, 3)
D.new BorderLayout(3, 4)
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
9
What is the default layout manager of the content pane of a JFrame?
A.FlowLayout
B.GridLayout
C.BoxLayout
D.BorderLayout
A.FlowLayout
B.GridLayout
C.BoxLayout
D.BorderLayout
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
10
What is the easiest way to create complex-looking GUI layouts?
I use the GridBagLayout manager
II nest panels, each with its own layout manager
III use multiple layout managers in the same container
A.Only I
B.Only II
C.Only III
D.I and III
I use the GridBagLayout manager
II nest panels, each with its own layout manager
III use multiple layout managers in the same container
A.Only I
B.Only II
C.Only III
D.I and III
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
11
Suppose a JPanel with a BorderLayout manager contains two components: component1, which was added to the CENTER, and component2, which was added to the SOUTH.Which parts of the JPanel will appear?
I North
II South
III Center
IV West
V East
A.I and II
B.I, II, and III
C.III, IV, and V
D.II and III
I North
II South
III Center
IV West
V East
A.I and II
B.I, II, and III
C.III, IV, and V
D.II and III
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
12
How do you add two buttons to the south area of a frame using the BorderLayout?
A.Add them to a panel, then add the panel to the SOUTH
B.Add one to the SOUTH, then add the second one to the SOUTH
C.Add one to the SOUTH, then add the second one to the CENTER
D.Add one to the CENTER, then add the second one to the SOUTH
A.Add them to a panel, then add the panel to the SOUTH
B.Add one to the SOUTH, then add the second one to the SOUTH
C.Add one to the SOUTH, then add the second one to the CENTER
D.Add one to the CENTER, then add the second one to the SOUTH
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
13
Which layout manager uses a grid so that each component will always be placed into an area of the same size?
I GridBagLayout
II BorderLayout
III GridLayout
A.Only I
B.Only II
C.Only III
D.I and III
I GridBagLayout
II BorderLayout
III GridLayout
A.Only I
B.Only II
C.Only III
D.I and III
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
14
When adding a component to a container with the ____ layout, specify the NORTH, EAST, SOUTH, WEST, or CENTER position.
A.border
B.grid
C.grid bag
D.flow
A.border
B.grid
C.grid bag
D.flow
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
15
What is the best first step in picking the layout managers for a set of nested panels?
A.use a single panel with a GridBagLayout manager
B.construct a set of JPanel objects
C.make a sketch of the layout
D.use multiple panels with FlowLayout managers
A.use a single panel with a GridBagLayout manager
B.construct a set of JPanel objects
C.make a sketch of the layout
D.use multiple panels with FlowLayout managers
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
16
Which layout manger would be best suited to create a simple navigation GUI with directional arrows for left, right, up, down and enter?
A.GridLayout
B.BorderLayout
C.FlowLayout
D.GridBagLayout
A.GridLayout
B.BorderLayout
C.FlowLayout
D.GridBagLayout
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
17
Which layout manager places objects left-to-right, and creates a new row only if when the current row cannot accommodate another object?
A.FlowLayout
B.BorderLayout
C.BoxLayout
D.GridLayout
A.FlowLayout
B.BorderLayout
C.BoxLayout
D.GridLayout
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
18
Which layout manager allows you to add components to it by invoking the container's add method with the component as the only argument to add.
I FlowLayout
II BorderLayout
III GridLayout
A.Only I
B.Only II
C.Only III
D.I and III
I FlowLayout
II BorderLayout
III GridLayout
A.Only I
B.Only II
C.Only III
D.I and III
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
19
The JFrame has a content pane with a default BorderLayout manager.Which method allows changing it to a FlowLayout manager?
A.setLayout
B.setFlowLayout
C.assignLayout
D.changeLayout
A.setLayout
B.setFlowLayout
C.assignLayout
D.changeLayout
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
20
Which class has constants called NORTH and SOUTH?
A.FlowLayout
B.BorderLayout
C.BoxLayout
D.GridLayout
A.FlowLayout
B.BorderLayout
C.BoxLayout
D.GridLayout
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
21
Which of the following is false about achieving complex layouts?
A.By giving each panel an appropriate layout manager, the panels can be nested
B.There are more complex layout managers such as the grid bag layout and group layout
C.You can use as many panels as you need to organize your components
D.The order of the nested panel does not matter
A.By giving each panel an appropriate layout manager, the panels can be nested
B.There are more complex layout managers such as the grid bag layout and group layout
C.You can use as many panels as you need to organize your components
D.The order of the nested panel does not matter
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
22
Suppose a JPanel with a BorderLayout manager contains two components: component1, which was added to the EAST, and component2, which was added to the WEST.Which parts of the JPanel appear?
I North
II South
III Center
IV West
V East
A.I and II
B.I, II, and III
C.III, IV, and V
D.IV and V
I North
II South
III Center
IV West
V East
A.I and II
B.I, II, and III
C.III, IV, and V
D.IV and V
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following classes have a user-editable area?
A.JCheckBox
B.JComboBox
C.ButtonGroup
D.JRadioButton
A.JCheckBox
B.JComboBox
C.ButtonGroup
D.JRadioButton
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
24
Which GUI element allows text entry from the program user?
A.ButtonGroup
B.JComboBox
C.JSlider
D.JPanel
A.ButtonGroup
B.JComboBox
C.JSlider
D.JPanel
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
25
Which of the following is true about a border layout?
A.It groups components into three areas: center, north, and south
B.It is the default manager for JPanel
C.Each area can hold a single component, or it can be empty
D.Components do not expand to fill in the space of the border layout
A.It groups components into three areas: center, north, and south
B.It is the default manager for JPanel
C.Each area can hold a single component, or it can be empty
D.Components do not expand to fill in the space of the border layout
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
26
Which method can a program use to set the selected choice in a JComboBox?
A.select
B.setChoice
C.setSelectedItem
D.The selection can only be set through the GUI by the user.
A.select
B.setChoice
C.setSelectedItem
D.The selection can only be set through the GUI by the user.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
27
Which of the following methods returns the object that was selected in the JComboBox?
A.getSelected
B.getItem
C.getChoice
D.getSelectedItem
A.getSelected
B.getItem
C.getChoice
D.getSelectedItem
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
28
When using a combo box, the _______ displays the name of the current selection.
A.text field
B.text area
C.menu item
D.submenu item
A.text field
B.text area
C.menu item
D.submenu item
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
29
Which of the following GUI objects generate(s) action events?
I JComboBox
II JRadioButton
III JButton
A.Only I
B.I and II
C.I and III
D.I, II and III
I JComboBox
II JRadioButton
III JButton
A.Only I
B.I and II
C.I and III
D.I, II and III
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
30
Insert the missing code in the following segment.The code intends to get the newly selected item from the combo box.
JComboBox facenameCombo = new JComboBox();
String selectedString = __________________________;
A.(String) facenameCombo.getSelected();
B.(String) facenameCombo.getSelectedItem();
C.(String) selectedString.getSelected();
D.(String) selectedString.getSelectedItem();
JComboBox facenameCombo = new JComboBox();
String selectedString = __________________________;
A.(String) facenameCombo.getSelected();
B.(String) facenameCombo.getSelectedItem();
C.(String) selectedString.getSelected();
D.(String) selectedString.getSelectedItem();
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
31
A ________ is a user-interface component with two states: checked and unchecked.
A.radio button
B.check box
C.menu item
D.submenu item
A.radio button
B.check box
C.menu item
D.submenu item
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
32
The statement that would add smallButton to the button group in the following code is _________.
JRadioButton smallButton = new JRadioButton("Small");
ButtonGroup group = new ButtonGroup();
A.group.add(new smallButton);
B.group.add(smallButton);
C.smallButton.add();
D.You cannot add smallButton to the button group.
JRadioButton smallButton = new JRadioButton("Small");
ButtonGroup group = new ButtonGroup();
A.group.add(new smallButton);
B.group.add(smallButton);
C.smallButton.add();
D.You cannot add smallButton to the button group.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
33
In an online job application, applicants have to submit a cover letter by typing it into a given text box.Which java class would be most appropriate for this text box?
A.JTextArea
B.JTextField
C.JLabel
D.JTextComponent
A.JTextArea
B.JTextField
C.JLabel
D.JTextComponent
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
34
Which of the following classes has a Boolean state that can be set or unset through the GUI?
A.JCheckBox
B.JButton
C.ButtonGroup
D.JMenuItem
A.JCheckBox
B.JButton
C.ButtonGroup
D.JMenuItem
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
35
Which of the following is not a visual component?
A.JRadioButton
B.JButton
C.ButtonGroup
D.JCheckBox
A.JRadioButton
B.JButton
C.ButtonGroup
D.JCheckBox
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
36
A(n) ____ is used when you have a large set of choices.
A.combo box
B.radio button
C.check box
D.action event
A.combo box
B.radio button
C.check box
D.action event
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
37
A ____ is a combination of a list and a text field.
A.radio button
B.combo box
C.check box
D.scroll bar
A.radio button
B.combo box
C.check box
D.scroll bar
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
38
What type of object can be added into a JComboBox by the addItem method?
A.Object
B.String
C.JRadioButton
D.any non-primitive type
A.Object
B.String
C.JRadioButton
D.any non-primitive type
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
39
What type does the method getSelectedItem in the JComboBox classreturn?
A.Object
B.String
C.JRadioButton
D.JLabel
A.Object
B.String
C.JRadioButton
D.JLabel
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
40
Which method can a program use to set the selected choice in a JRadioButton?
A.set
B.setChoice
C.setSelectedItem
D.setSelected
A.set
B.setChoice
C.setSelectedItem
D.setSelected
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
41
What is known for certain from this correct code excerpt?
ActionListener openListener = new FileOpenListener();
JMenuItem fileOpen = new JMenuItem("Open File");
fileOpen.addActionListener(openListener);
A.fileOpen will open a file dialog when clicked
B.The fileOpen menu item will be visible
C.The FileOpenListener class implements the ActionListener interface
D.The openListener object will only listen to the fileOpen object
Title
What is known for certain from this correct code excerpt?
type
mc
ActionListener openListener = new FileOpenListener();
JMenuItem fileOpen = new JMenuItem("Open File");
fileOpen.addActionListener(openListener);
A.fileOpen will open a file dialog when clicked
B.The fileOpen menu item will be visible
C.The FileOpenListener class implements the ActionListener interface
D.The openListener object will only listen to the fileOpen object
Title
What is known for certain from this correct code excerpt?
type
mc
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
42
What is wrong with the following code?
class ExitListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
System.exit(0);
}
}
ActionListener exitListener = new ExitListener();
JMenu exitMenu = new JMenu("Exit");
exitMenu.addActionListener(exitListener);
JMenuBar menuBar = new JMenuBar();
menuBar.add(exitMenu);
A.The ExitListener class is not public
B.You cannot attach a listener to a menu, only to a menu item
C.You cannot add a menu to the menu bar, only a menu item
D.You need to use a menu listener, not an action listener
Title
What is wrong with the following menu code?
type
mc
class ExitListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
System.exit(0);
}
}
ActionListener exitListener = new ExitListener();
JMenu exitMenu = new JMenu("Exit");
exitMenu.addActionListener(exitListener);
JMenuBar menuBar = new JMenuBar();
menuBar.add(exitMenu);
A.The ExitListener class is not public
B.You cannot attach a listener to a menu, only to a menu item
C.You cannot add a menu to the menu bar, only a menu item
D.You need to use a menu listener, not an action listener
Title
What is wrong with the following menu code?
type
mc
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
43
What features do GUI builders have to speed the development of the graphical user interface of the program?
I setting properties of dialog boxes
II automated event-handling code generation
III drag and drop of visual components
A.I
B.II
C.II and III
D.I, II and III
I setting properties of dialog boxes
II automated event-handling code generation
III drag and drop of visual components
A.I
B.II
C.II and III
D.I, II and III
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
44
If the method makeMenuItem is called four times, how many MyMenuListener objects will be created?
public JMenuItem makeMenuItem(String menuLabel)
{
JMenuItem mi = new JMenuItem(menuLabel);
class MyMenuListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
doSomething();
}
}
mi.addActionListener(new MyMenuListener());
return mi;
}
A.1
B.2
C.3
D.4
public JMenuItem makeMenuItem(String menuLabel)
{
JMenuItem mi = new JMenuItem(menuLabel);
class MyMenuListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
doSomething();
}
}
mi.addActionListener(new MyMenuListener());
return mi;
}
A.1
B.2
C.3
D.4
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
45
Which elements of creating a graphical user interface are made easier by a GUI builder?
I creating event handlers
II configuring component properties
III adding components
A.Only II
B.I and II
C.I and III
D.I, II, and III
I creating event handlers
II configuring component properties
III adding components
A.Only II
B.I and II
C.I and III
D.I, II, and III
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
46
You can add a(n) _________ to a panel to make it visible.
A.component
B.JFrame
C.border
D.another panel
Title
You can add a ____ to a panel to make it visible.
type
mc
A.component
B.JFrame
C.border
D.another panel
Title
You can add a ____ to a panel to make it visible.
type
mc
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
47
Which of the following generate action events?
A.Buttons
B.Menu items
C.Combo box
D.All of the above
A.Buttons
B.Menu items
C.Combo box
D.All of the above
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
48
What is the most time-effective way to build a GUI quickly and concentrate on coding the logic of the program?
A.use the GridBagLayout manager
B.use a GUI builder, such as NetBeans
C.use nested panels
D.use menus
A.use the GridBagLayout manager
B.use a GUI builder, such as NetBeans
C.use nested panels
D.use menus
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
49
If the makeMenuItem method is called four times, at most how many
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
50
Which component can be added to a menu?
I JMenuBar
II JMenu
III JMenuItem
A.Only I
B.I and II
C.II and III
D.I, II and III
I JMenuBar
II JMenu
III JMenuItem
A.Only I
B.I and II
C.II and III
D.I, II and III
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
51
Which of the following would be an appropriate use of radio buttons when ordering a pizza?
A.Topping choices
B.Customer's name
C.Pick-up/Delivery
D.Types of sides
A.Topping choices
B.Customer's name
C.Pick-up/Delivery
D.Types of sides
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
52
What can be determined about obj from the code below?
JMenuItem menuItem = new JMenuItem("Exit");
menuItem.addActionListener(obj);
A.The class of obj implements ActionListener
B.menuItem implements ActionListener
C.obj is of type MenuListener
D.obj is an object of an inner class
JMenuItem menuItem = new JMenuItem("Exit");
menuItem.addActionListener(obj);
A.The class of obj implements ActionListener
B.menuItem implements ActionListener
C.obj is of type MenuListener
D.obj is an object of an inner class
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
53
Based on the statement below, which of the following adds a title to the border?
JPanel panel = new JPanel();
A.panel.setBorder(new TitledBorder());
B.panel.setBorder(new TitledBorder(new EtchedBorder(), "Size"));
C.panel.setBorder(new TitledBorder(new EtchedBorder()));
D.panel.setTitle("Size");
Title
Which of the following adds a title to the border?
type
mc
JPanel panel = new JPanel();
A.panel.setBorder(new TitledBorder());
B.panel.setBorder(new TitledBorder(new EtchedBorder(), "Size"));
C.panel.setBorder(new TitledBorder(new EtchedBorder()));
D.panel.setTitle("Size");
Title
Which of the following adds a title to the border?
type
mc
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
54
Which of the following defines the job of a ButtonGroup?
A.Places the buttons close to each other in the container
B.Assures only one button in the group is selected at a time
C.Arranges the group of buttons solely for presentation purposes
D.Groups checkboxes together to allow multiple choices
A.Places the buttons close to each other in the container
B.Assures only one button in the group is selected at a time
C.Arranges the group of buttons solely for presentation purposes
D.Groups checkboxes together to allow multiple choices
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
55
Which of the following adds a border to the following panel?
JPanel panel = new JPanel();
A.panel.addEtchedBorder();
B.panel.addBorder(new EtchedBorder());
C.panel.add(new EtchedBorder());
D.panel.setBorder(new EtchedBorder());
Title
Which statement adds a border to this panel?
type
mc
JPanel panel = new JPanel();
A.panel.addEtchedBorder();
B.panel.addBorder(new EtchedBorder());
C.panel.add(new EtchedBorder());
D.panel.setBorder(new EtchedBorder());
Title
Which statement adds a border to this panel?
type
mc
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
56
When a menu item is selected, what type of event does it send?
A.ActionEvent
B.ChangeEvent
C.ItemEvent
D.SelectionEvent
Title
When a menu item is selected, what type of event does it send?
type
mc
A.ActionEvent
B.ChangeEvent
C.ItemEvent
D.SelectionEvent
Title
When a menu item is selected, what type of event does it send?
type
mc
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
57
When the user selects a menu item, the menu item sends a(n) ___________________.
A.ActionEvent
B.ChangeEvent
C.ItemEvent
D.MouseEvent
A.ActionEvent
B.ChangeEvent
C.ItemEvent
D.MouseEvent
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
58
Examine the code below.What type of class is MyMenuListener?
public JMenuItem makeMenuItem(String menuLabel)
{
JMenuItem mini = new JMenuItem(menuLabel);
class MyMenuListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
doSomething();
}
}
mini.addActionListener(new MyMenuListener());
return mi;
}
A.It is an anonymous class
B.It is an inner class
C.It is a JMenuItem subclass
D.It is a JMenu class
public JMenuItem makeMenuItem(String menuLabel)
{
JMenuItem mini = new JMenuItem(menuLabel);
class MyMenuListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
doSomething();
}
}
mini.addActionListener(new MyMenuListener());
return mi;
}
A.It is an anonymous class
B.It is an inner class
C.It is a JMenuItem subclass
D.It is a JMenu class
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
59
Given four JRadioButton objects in a ButtonGroup, how many radio buttons can be selected at the same time?
A.1
B.2
C.4
D.3
A.1
B.2
C.4
D.3
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
60
What is the container for top-level menu items?
A.menu bar
B.menu item
C.menu GUI
D.top level menus don't use containers
A.menu bar
B.menu item
C.menu GUI
D.top level menus don't use containers
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
61
For a new programmer using the Swing JSlider component for the first time, which of these is the least important thing to know?
A.A basic way to construct a JSlider
B.What type of events it generates
C.How to write the BoundedRangeModel constructor
D.Its value when an event occurs
A.A basic way to construct a JSlider
B.What type of events it generates
C.How to write the BoundedRangeModel constructor
D.Its value when an event occurs
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
62
What is the general order of a pull-down menu (from top-level going downwards)?
A.Frame, menu bar, menus, submenus, menu items
B.Menus, menu bar, submenus, frame, menu items
C.Menu bar, frame, menus, submenus, menu items
D.Submenus, menus, frame, menu bar, menu items
A.Frame, menu bar, menus, submenus, menu items
B.Menus, menu bar, submenus, frame, menu items
C.Menu bar, frame, menus, submenus, menu items
D.Submenus, menus, frame, menu bar, menu items
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
63
Which code will create a JSlider with a range from 0 to 100, with an initial value of 50?
I new JSlider()
II new JSlider(0, 100, 50)
III new JSlider(50, 0, 100)
A.Only I
B.Only II
C.Only III
D.I and II
I new JSlider()
II new JSlider(0, 100, 50)
III new JSlider(50, 0, 100)
A.Only I
B.Only II
C.Only III
D.I and II
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
64
What code would be the most appropriate assist in getting notified when a user interacts with a JSlider?
A.public JSlider(BoundedRangeModel brm)
B.public void addChangeListener(ChangeListener l)
C.JSlider()
D.public JSlider(int min, int max, int value)
A.public JSlider(BoundedRangeModel brm)
B.public void addChangeListener(ChangeListener l)
C.JSlider()
D.public JSlider(int min, int max, int value)
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
65
What method is required by the ChangeListener interface?
A.changeOccured
B.actionPerformed
C.stateChanged
D.sliderMoved
A.changeOccured
B.actionPerformed
C.stateChanged
D.sliderMoved
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
66
What type of event does the JSlider class generate?
A.ChangeEvent
B.ActionEvent
C.ItemEvent
D.SliderEvent
A.ChangeEvent
B.ActionEvent
C.ItemEvent
D.SliderEvent
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
67
Consider the scope of the three objects menuLabel, mi, and the anonymous object new MyMenuListener() within the JmenuItem class.How do thier lifetimes compare?
public JMenuItem makeMenuItem(final String menuLabel)
{
JMenuItem mi = new JMenuItem(menuLabel);
class MyMenuListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
doSomethingElse();
System.out.println(menuLabel);
}
}
mi.addActionListener(new MyMenuListener());
return mi;
}
A.all have the same lifetimes
B.menuLabel and new MyMenuListener() are the same and both longer than mi
C.mi and new MyMenuListener() are the same and both longer than menuLabel
D.from shortest to longest:menuLabel, new MyMenuListener(), mi
public JMenuItem makeMenuItem(final String menuLabel)
{
JMenuItem mi = new JMenuItem(menuLabel);
class MyMenuListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
doSomethingElse();
System.out.println(menuLabel);
}
}
mi.addActionListener(new MyMenuListener());
return mi;
}
A.all have the same lifetimes
B.menuLabel and new MyMenuListener() are the same and both longer than mi
C.mi and new MyMenuListener() are the same and both longer than menuLabel
D.from shortest to longest:menuLabel, new MyMenuListener(), mi
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
68
The ChangeEvent class defines no methods.What makes it possible to call the getSource method on a ChangeEvent object?
A.The method is inherited from the Object class.
B.You have to code that method yourself.
C.The method is inherited from the EventObject class.
D.ChangeEvent implements the Event interface
A.The method is inherited from the Object class.
B.You have to code that method yourself.
C.The method is inherited from the EventObject class.
D.ChangeEvent implements the Event interface
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
69
The code below will not compile successfully unless the argument to the makeMenuItem method is final.Why not?
public JMenuItem makeMenuItem(final String menuLabel)
{
JMenuItem mi = new JMenuItem(menuLabel);
class MyMenuListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
doSomethingElse();
System.out.println(menuLabel);
}
}
mi.addActionListener(new MyMenuListener());
return mi;
}
A.JMenuItem labels must be final
B.This prevents the menuLabel argument from being modified
C.Because a local variable is being accessed from an inner classes
D.Because the String class is final
public JMenuItem makeMenuItem(final String menuLabel)
{
JMenuItem mi = new JMenuItem(menuLabel);
class MyMenuListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
doSomethingElse();
System.out.println(menuLabel);
}
}
mi.addActionListener(new MyMenuListener());
return mi;
}
A.JMenuItem labels must be final
B.This prevents the menuLabel argument from being modified
C.Because a local variable is being accessed from an inner classes
D.Because the String class is final
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
70
The event that is generated by a slider when its value changes is of type _____.
A.ActionEvent
B.ChangeEvent
C.ItemEvent
D.MouseEvent
A.ActionEvent
B.ChangeEvent
C.ItemEvent
D.MouseEvent
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
71
What can you add action listeners to?
A.Menu items
B.Menus
C.Menu bar
D.Submenu
A.Menu items
B.Menus
C.Menu bar
D.Submenu
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
72
Which of the following statements is correct?
A.new JSlider() creates a horizontal slider with the range 0 to 200 and an initial value of 100.
B.new JSlider() creates a horizontal slider with the range 0 to 10 and an initial value of 5.
C.new JSlider() creates a horizontal slider with the range 0 to 100 and an initial value of 50.
D.new JSlider() creates a horizontal slider with the range 0 to 150 and an initial value of 100.
A.new JSlider() creates a horizontal slider with the range 0 to 200 and an initial value of 100.
B.new JSlider() creates a horizontal slider with the range 0 to 10 and an initial value of 5.
C.new JSlider() creates a horizontal slider with the range 0 to 100 and an initial value of 50.
D.new JSlider() creates a horizontal slider with the range 0 to 150 and an initial value of 100.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
73
When method makeMenuItem is called, how many objects are being created?
public JMenuItem makeMenuItem(final String menuLabel)
{
JMenuItem mi = new JMenuItem(menuLabel);
class MyMenuListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
doSomethingElse();
System.out.println(menuLabel);
}
}
mi.addActionListener(new MyMenuListener());
return mi;
}
A.1
B.2
C.3
D.4
public JMenuItem makeMenuItem(final String menuLabel)
{
JMenuItem mi = new JMenuItem(menuLabel);
class MyMenuListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
doSomethingElse();
System.out.println(menuLabel);
}
}
mi.addActionListener(new MyMenuListener());
return mi;
}
A.1
B.2
C.3
D.4
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
74
If one ChangeListener is listening for three
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
75
The _______ interface toolkit has a large set of user-interface components.
A.GUI Builder
B.graphical user
C.Swing
D.JMenu
A.GUI Builder
B.graphical user
C.Swing
D.JMenu
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck