Exam 14: Introduction to Swing Components

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags
Match each term with the correct statement below.
Premises:
A method that executes because it is called automatically when an appropriate event occurs
Responses:
look and feel
lightweight components
editable
Correct Answer:
Verified
Premises:
Responses:
A method that executes because it is called automatically when an appropriate event occurs
look and feel
Free
(Matching)
4.9/5
(40)
Correct Answer:
Verified

How do you change the font of a JLabel ?

Free
(Essay)
4.7/5
(41)
Correct Answer:
Verified

To give a JLabel object a new font, you can create a Font object, as in the following:
Font headlineFont = new Font("Monospaced", Font.BOLD, 36);
The typeface name is a String , so you must enclose it in double quotation marks when you use it to declare the Font object. Then you use the setFont() method to assign the Font to a JLabel with a statement such as:
greeting.setFont(headlineFont);

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

Free
(True/False)
5.0/5
(33)
Correct Answer:
Verified

False

import javax.swing.*; public class JFrameLabel {     public static void main(String[] args)     {        final int FRAME_WIDTH = 300;        final int FRAME_HEIGHT = 120;        JFrame myFrame = new JFrame("Frame with label");        myFrame.setSize(FRAME_WIDTH, FRAME_HEIGHT);        myFrame.setVisible(true);        myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        -----Code here-----        -----Code here-----      } } The above code shows an application in which a JFrame is created and its size, visibility, and close operation are set. In the indicated lines provided, write the code to create a JLabel named thanks that holds the words "Thank you for your business". Then, write the statement to add the JLabel to the JFrame .

(Essay)
4.7/5
(39)

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

(Essay)
4.8/5
(37)

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".

(Essay)
4.8/5
(35)

When you create a(n) ____, you can group several components, such as JCheckBox es, so a user can select only one at a time.

(Multiple Choice)
4.8/5
(40)

Which of the following statements will change the value displayed in a JLabel named hello ?

(Multiple Choice)
4.8/5
(33)

Write the statement to create a layout manager named myLayout that centers components in each row.

(Short Answer)
4.9/5
(30)

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

(Multiple Choice)
4.8/5
(34)
Match each term with the correct statement below.
Premises:
An object that is interested in an event
Responses:
lightweight components
heavyweight components
look and feel
Correct Answer:
Verified
Premises:
Responses:
An object that is interested in an event
lightweight components
(Matching)
4.9/5
(41)

A ____ is a component that combines a button or an editable field and a drop-down list.

(Multiple Choice)
4.8/5
(36)

What is the default layout manager for JFrame ?

(Multiple Choice)
4.9/5
(35)

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.

(Essay)
4.7/5
(36)

Which constructor constructs a new JTextField with the specified text and columns?

(Multiple Choice)
4.7/5
(36)

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

(Essay)
4.8/5
(36)
Match each term with the correct statement below.
Premises:
Require interaction with the local operating system
Responses:
editable
point size
frame
Correct Answer:
Verified
Premises:
Responses:
Require interaction with the local operating system
editable
(Matching)
4.7/5
(40)

Look and feel comprises the elements of design, style, and ____ in any user interface.

(Multiple Choice)
4.7/5
(41)

When a user closes a JFrame by clicking the Close button in the upper-right corner, the default behavior is for the JFrame to close and the application to terminate.

(True/False)
4.8/5
(48)

What are some of the decisions you must make when extending a JFrame ?

(Essay)
4.9/5
(45)
Showing 1 - 20 of 79
close modal

Filters

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