• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/54

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

54 Cards in this Set

  • Front
  • Back

You can use this method to make a text field read-only.a. setReadOnlyb. setChangeablec. setUneditabled. setEditable

1. d

A JList component generates this type of event when the user selects an item.a. action eventb. item eventc. list selection eventd. list change event

2. c

To display a scroll bar with a JList component, you must __________.a. do nothing; the JList automatically appears with scroll bars if necessaryb. add the JList component to a JScrollPane componentc. call the setScrollBar methodd. none of the above; you cannot display a scroll bar with a JList component

3. b

This is the JList component’s default selection mode.a. single selectionb. single interval selectionc. multiple selectiond. multiple interval selection

4. d

A list selection listener must have this method.a. valueChangedb. selectionChangedc. actionPerformedd. itemSelected

5. a

The ListSelectionListener interface is in this package.a. java.awtb. java.awt.eventc. javax.swing.eventd. javax.event

6. c

This JList method returns 21 if no item in the list is selected.a. getSelectedValueb. getSelectedItemc. getSelectedIndexd. getSelection

7. c

A JComboBox component generates this type of event when the user selects an item.a. action eventb. item eventc. list selection eventd. list change event

8. a

You can pass an instance of this class to the JLabel constructor if you want to displayan image in the label.a. ImageFileb. ImageIconc. JLabelImaged. JImageFile

9. b

This method can be used to store an image in a JLabel or a JButton component.a. setImageb. storeImagec. getIcond. setIcon

10. d

This is text that appears in a small box when the user holds the mouse cursor over a component. a. mnemonic b. instant message c. tool tip d. pop-up mnemonic

11. c

This is a key that activates a component just as if the user clicked it with the mouse. a. mnemonic b. key activator c. tool tip d. click simulator

12. a

To display an open file or save file dialog box, you use this class.a. JFileChooserb. JOpenSaveDialogc. JFileDialogd. JFileOptionPane

13. a

To display a dialog box that allows the user to select a color, you use this class.a. JColorb. JColorDialogc. JColorChooserd. JColorOptionPane

14. c

You use this class to create a menu bar.a. MenuBarb. JMenuBarc. JMenud. JBar

15. b

You use this class to create a radio button menu item.a. JMenuItemb. JRadioButtonc. JRadioButtonItemd. JRadioButtonMenuItem

16. d

You use this method to place a menu bar on a JFrame.a. setJMenuBarb. setMenuBarc. placeMenuBard. setJMenu

17. a

The setPreferredSize method accepts this as its argument(s).a. a Size objectb. two int valuesc. a Dimension objectd. one int value

18. c

Components of this class are multi-line text fields.a. JMultiLineTextFieldb. JTextAreac. JTextFieldd. JEditField

19. b

This method is inherited from JComponent and changes the appearance of a component’stext.a. setAppearanceb. setTextAppearancec. setFontd. setText

20. c

This method sets the intervals at which major tick marks are displayed on a JSlidercomponent.a. setMajorTickSpacingb. setMajorTickIntervalsc. setTickSpacingd. setIntervals

21. a

True or False: You can use code to change the contents of a read-only text field.

22. True

True or False: A JList component automatically appears with a line border drawn around it.

23. False

True or False: In single interval selection mode, the user may select multiple items from a JList component.

24. True

True or False: With an editable combo box the user may only enter a value that appears in the component’s list.

25. False

True or False: You can store either text or an image in a JLabel object, but not both.

26. False

True or False: You can store large images as well as small ones in a JLabel component.

27. True

True or False: Mnemonics are useful for users who are good with the keyboard.

28. True

True or False: A JMenuBar object acts as a container for JMenu components.

29. True

True or False: A JMenu object cannot contain other JMenu objects.

30. False

True or False: A JTextArea component does not automatically display scroll bars.

31. True

True or False: By default, a JTextArea component does not perform line wrapping.

32. True

True or False: A JSlider component generates an action event when the slider knob is moved.

33. False

True or False: By default, a JSlider component displays labels and tick marks.

34. False

True or False: When labels are displayed on a JSlider component, they are displayed on the major tick marks.

35. True

// Create a read-only text field.


JTextField textField = new JTextField(10);textField.setEditable(true);

The argument falseshould have been passed to the setEditablemethod.

// Create a black 1-pixel border around list, a JList component.list.setBorder(Color.BLACK, 1);

The code should read: list.setBorder(BorderFactory.createLineBorder(Color.black, 1));

// Create a JList and add it to a scroll pane.


// Assume that array already exists.


JList list = new JList(array);


JScrollPane scrollPane = new JScrollPane();scrollPane.add(list);

You should pass list as an argument to the JScrollPane constructor: JScrollPane scrollPane = new JScrollPane(list);

// Assume that nameBox is a combo box and is properly set up


// with a list of names to choose from.


// Get value of the selected item.


String selectedName = nameBox.getSelectedIndex();

The statement should read: String selectedName = (String) nameBox.getSelectedItem();

JLabel label = new JLabel("Have a nice day!");label.setImage(image);

The second statement should read: label.setIcon(image);

// Add a menu to the menu bar.


JMenuBar menuBar = new JMenuBar(menuItem);

You pass a JMenu object as an argument to the JMenuBar object's add method: JMenuBar menuBar = new JMenuBar(); menuBar.add(menu);

// Create a text area with 20 columns and 5 rows.


JTextArea textArea = new JTextArea (20, 5);

The statement should read: JTextArea textArea = new JTextArea (5, 20);

What selection mode should you select if you want the user to select a single item onlyin a list?

Single selection mode

You want to provide 20 items in a list for the user to select from. Which component would take up less space, a JList or a JComboBox?

JComboBox

What is the difference between an uneditable combo box and an editable combo box? Which one is a combo box by default?

An uneditable combo box combines a button with a list, and allows the user to only select items from its list. An editable combo box combines a text field and a list. In addition to selecting items from the list, the user may also type input into the text field. The default type of combo box is uneditable.

Describe how you can store both an image and text in a JLabel component.

You can pass the text as an argument to the constructor, and then pass an ImageIcon object to the setIcon method. Another way is to pass the text, an ImageIcon object, and an int specifying horizontal alignment to the JLabel constructor.

What is a mnemonic? How does the user use it?

A mnemonic is a key on the keyboard that you press in combination with the Alt key to quickly access a component such as a button. When you assign a mnemonic to a button, the user can click the button by holding down the Alt key and pressing the mnemonic key.

What happens when the mnemonic that you assign to a component is a letter that appears in the component’s text?

The first occurrence of that letter appears underlined.

What is a tool tip? What is its purpose?

A tool tip is text that is displayed in a small box when the user holds the mouse cursor over a component. The box usually gives a short description of what the component does.

What do you do to a group of radio button menu items so that only one of them can be selected at a time?

Add them to a ButtonGroup object.

When a checked menu item shows a check mark next to it, what happens when the user clicks on it?

The item is deselected, which causes the check mark to disappear. The checked menu item component also generates an action event.

What fonts does Java guarantee you have?

Dialog, DialogInput, SansSerif, Serif, and Monospaced

Why would a JSlider component be ideal when you want the user to enter a number, but you want to make sure that the number is within a range?

Because, as the user moves the JSlider component's knob, it will only take on values within its established range.

What are the standard GUI looks and feels that are available in Java?

Metal, Motif, and Windows