Exam 14: Introduction to Swing Components

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

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

(Essay)
4.9/5
(41)

Provide an example of an event-driven program.

(Essay)
4.9/5
(36)

Create the statements to construct two JFrame s. One JFrame should be declared as welcomeFrame and have the title "Welcome", and the second JFrame should be declared as noTitleFrame and have no title.

(Essay)
4.8/5
(41)
Match each term with the correct statement below.
A JTextField that has the capability of accepting keystrokes
editable
Require interaction with the local operating system
event handler
A method that executes because it is called automatically when an appropriate event occurs
layout manager
Correct Answer:
Verified
Premises:
Responses:
A JTextField that has the capability of accepting keystrokes
editable
Require interaction with the local operating system
event handler
A method that executes because it is called automatically when an appropriate event occurs
layout manager
A class that controls component positioning
point size
Arial, Century, Monospaced, and Times New Roman
lightweight components
The measurement between lines of text in a single-spaced text document
heavyweight components
Popup windows that can help a user understand the purpose of components in an application
tool tips
A coffee-cup icon in the frame's title bar, and the Minimize, Restore, and Close buttons
window decorations
Are written completely in Java and do not have to rely on the local operating system code
fonts
(Matching)
4.9/5
(32)

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?");      -----Code here-----      aFrame.add(greeting);      aFrame.add(greeting2);    } } Using the above code, write the FlowLayout statement in the indicated line that will display the two greeting JLabel s side by side.

(Short Answer)
4.9/5
(38)

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

(True/False)
4.8/5
(29)

What are the tasks you must perform when you declare a class that handles an event?

(Essay)
4.9/5
(32)

Swing components are UI elements such as dialog boxes and buttons. You can usually recognize their names because they begin with the letter ____________________.

(Short Answer)
5.0/5
(33)

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

(Multiple Choice)
4.8/5
(40)

Describe a flow layout manager compared to a border layout manager.

(Essay)
4.8/5
(37)

Write the statement to clear out a JTextField named myText .

(Short Answer)
4.8/5
(35)

Each Swing component is a descendant of a JComponent .

(True/False)
4.8/5
(37)

The ____ responds to keyboard events.

(Multiple Choice)
4.7/5
(39)

The JButton , JCheckBox , JComboBox , and JRadioButton components are associated with the ____ method.

(Multiple Choice)
4.8/5
(39)

In a(n) ____________________ program, the user might initiate any number of events in any order.

(Short Answer)
4.7/5
(33)

If a user enters more characters than specified in a JTextField , the extra characters are deleted.

(True/False)
5.0/5
(36)

import javax.swing.*; import java.awt.*; public class JFrame4 {    public static void main(String[] args)    {       final int FRAME_WIDTH = 250;       final int FRAME_HEIGHT = 100;       -----Code here-----       JFrame aFrame = new JFrame("Fourth frame");       aFrame.setSize(FRAME_WIDTH, FRAME_HEIGHT);      aFrame.setVisible(true);      aFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);      JLabel greeting = new JLabel("Good day");      -----Code here-----      aFrame.add(greeting);    } } In the first indicated line, write the statement to create a Font object named myLook with a typeface of Times New Roman, italic, and 30-point size. In the second indicated line, create the statement to apply myLook to the greeting JLabel .

(Essay)
4.8/5
(36)

The ____________________ layout manager places components in a row, and when a row is filled, it automatically spills components into the next row.

(Short Answer)
4.8/5
(40)

What are the four JFrame constructors?

(Essay)
4.9/5
(39)

Write the statement to create a JCheckBox object named feeWaived that is selected. Include the label "Fee Waived".

(Short Answer)
4.8/5
(31)
Showing 41 - 60 of 66
close modal

Filters

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