Exam 14: Introduction to Swing Components

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

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); _________________________ _________________________ } } The above code shows an application in which a JFrame is created and its size, visibility, and close operation are set. In the blank 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.9/5
(39)

What is the default layout manager for JFrame?

(Multiple Choice)
4.8/5
(29)

What class is the immediate parent of JFrame?

(Multiple Choice)
4.7/5
(38)

Within an event-driven program, a component on which an event is generated is the ____ of the event.

(Multiple Choice)
4.9/5
(39)

Write the statement to create a JButton named submitButton with the label "Submit your data".

(Essay)
4.8/5
(28)

A(n) ____________________ is the default appearance and behavior of any user interface.

(Short Answer)
4.9/5
(35)

Write the statement to add a tool tip that displays "Submit your form" to a button named submit.

(Essay)
4.9/5
(32)

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; ________________________ 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"); ________________________ aFrame.add(greeting); } } In the first blank line provided, 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 blank line, create the statement to apply myLook to the greeting JLabel.

(Essay)
4.8/5
(32)

Match each term with the correct statement below. -Are written completely in Java and do not have to rely on the local operating system code

(Multiple Choice)
4.7/5
(31)

Match each term with the correct statement below. -The measurement between lines of text in a single-spaced text document

(Multiple Choice)
5.0/5
(40)

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.9/5
(42)

How can you customize the appearance of a JFrame?

(Essay)
4.8/5
(32)

How do you change the font of a JLabel?

(Essay)
5.0/5
(38)

Write the statement to clear out a JTextField named myText.

(Essay)
4.8/5
(36)

import javax.swing.*; public class JFrame1 { public static void main(String[] args) { JFrame aFrame = new JFrame("First frame"); aFrame.setSize(300, 125); aFrame.setVisible(true); } } The three shaded statements in the main() method above are important. Explain the purpose of each statement and why they are necessary for creating a JFrame.

(Essay)
4.8/5
(42)

Match each term with the correct statement below. -Arial, Century, Monospaced, and Times New Roman

(Multiple Choice)
4.8/5
(33)

Create the statements to construct two JFrames. 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
(43)

Provide an example of an event-driven program.

(Essay)
4.8/5
(41)

Each Swing component is a descendant of a JComponent.

(True/False)
4.8/5
(36)

You can use the setEnabled() method to make a component unavailable and then make it available again in turn.

(True/False)
4.9/5
(41)
Showing 41 - 60 of 74
close modal

Filters

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