Exam 14: Introduction to Swing Components
Exam 1: Creating Your First Java Classes76 Questions
Exam 2: Using Data81 Questions
Exam 3: Using Methods, Classes and Objects79 Questions
Exam 4: More Object Concepts84 Questions
Exam 5: Making Decisions80 Questions
Exam 6: Looping77 Questions
Exam 7: Characters, Strings and the Stringbuilder82 Questions
Exam 8: Arrays77 Questions
Exam 9: Advanced Array Concepts80 Questions
Exam 10: Introduction to Inheritance78 Questions
Exam 11: Advanced Inheritance Concepts78 Questions
Exam 12: Exception Handling79 Questions
Exam 13: File Input and Output78 Questions
Exam 14: Introduction to Swing Components79 Questions
Exam 15: Using Javafx and Scene Builder65 Questions
Select questions type
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:
Premises:
Responses:
Free
(Matching)
4.9/5
(40)
Correct Answer:
How do you change the font of a JLabel ?
Free
(Essay)
4.7/5
(41)
Correct Answer:
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:
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:
Premises:
Responses:
(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)
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)
Match each term with the correct statement below.
Premises:
Require interaction with the local operating system
Responses:
editable
point size
frame
Correct Answer:
Premises:
Responses:
(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
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)