Exam 14: Introduction to Swing Components

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Which of the following statements will correctly set a JFrame named myFrame to be visible?

Free
(Multiple Choice)
4.9/5
(40)
Correct Answer:
Verified

B

The ____ method of JComboBox returns the maximum number of items the combo box can display without a scroll bar.

Free
(Multiple Choice)
4.7/5
(30)
Correct Answer:
Verified

C

Assume you have declared a JFrame named welcomeFrame. Write the statement to set the welcomeFrame object's size to 300 pixels horizontally by 110 pixels vertically. Create a second statement to set the JFrame's title to display the text "My Sized Frame".

Free
(Essay)
4.9/5
(38)
Correct Answer:
Verified

welcomeFrame.setSize(300, 110);
welcomeFrame.setTitle("My Sized Frame");

An object that is interested in an event is called a source.

(True/False)
4.9/5
(41)

A ____ is a component that combines two features: a display area showing an option, and a list box containing additional options.

(Multiple Choice)
4.8/5
(39)

Java provides you with a Font class from which you can create an object that holds typeface and size information.

(True/False)
4.9/5
(45)

Match each term with the correct statement below. -A class that controls component positioning

(Multiple Choice)
4.9/5
(28)

What is the immediate parent class of JTextField?

(Multiple Choice)
4.8/5
(29)

A component can be made available or unavailable by passing true or false to the ____ method.

(Multiple Choice)
4.7/5
(32)

Match each term with the correct statement below. -A JTextField that has the capability of accepting keystrokes

(Multiple Choice)
4.7/5
(37)

The default behavior of a JFrame is to use the BorderLayout format, which divides a container into regions.

(True/False)
4.8/5
(35)

If a user enters more characters than specified in a JTextField, the extra characters scroll out of view.

(True/False)
4.8/5
(36)

When a JFrame is closed, you can end a program that you have forgotten to exit by typing Ctrl+E.

(True/False)
4.9/5
(39)

Match each term with the correct statement below. -A method that executes because it is called automatically when an appropriate event occurs

(Multiple Choice)
4.8/5
(34)

The ____ responds to keyboard focus events.

(Multiple Choice)
4.8/5
(40)

How do you change the text of a JLabel? Provide an example.

(Essay)
4.9/5
(43)

The JLabel constructor ____ creates a JLabel instance with the specified image and horizontal alignment.

(Multiple Choice)
4.8/5
(36)

The Swing classes are part of a more general set of UI programming capabilities that are collectively called the ____.

(Multiple Choice)
4.7/5
(30)

What are the four JFrame constructors?

(Essay)
4.7/5
(40)

import javax.swing.*; import java.awt.*; public class JFrame6 { public static void main(String[] args) { final int FRAME_WIDTH = 250; final int FRAME_HEIGHT = 100; JFrame aFrame = new JFrame("Sixth frame"); aFrame.setSize(FRAME_WIDTH, FRAME_HEIGHT); aFrame.setVisible(true); aFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel greeting = new JLabel("Hello"); JLabel greeting2 = new JLabel("Who are you?"); _________________________ aFrame.add(greeting); aFrame.add(greeting2); } } Using the above code, write the FlowLayout statement in the blank line provided that will display the two greeting JLabels side by side.

(Essay)
4.8/5
(39)
Showing 1 - 20 of 74
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)