Exam 15: Advanced Gui Topics
Exam 1: Creating Java Programs68 Questions
Exam 2: Using Data74 Questions
Exam 3: Using Methods, Classes, and Objects68 Questions
Exam 4: More Object Concepts67 Questions
Exam 5: Making Decisions70 Questions
Exam 6: Looping72 Questions
Exam 7: Characters, Strings, and the Stringbuilder73 Questions
Exam 8: Arrays74 Questions
Exam 9: Advanced Array Concepts74 Questions
Exam 10: Introduction to Inheritance70 Questions
Exam 11: Advanced Inheritance Concepts70 Questions
Exam 12: Exception Handling65 Questions
Exam 13: File Input and Output74 Questions
Exam 14: Introduction to Swing Components74 Questions
Exam 15: Advanced Gui Topics69 Questions
Exam 16: Graphics74 Questions
Exam 17: Applets, Images, and Sound72 Questions
Select questions type
Use the ____ layout manager when you need to add components that are displayed one at a time.
Free
(Multiple Choice)
4.9/5
(33)
Correct Answer:
D
The wildcard in the import java.awt.* statement imports all types in the java.awt package, including java.awt.Color and java.awt.Font.
Free
(True/False)
4.9/5
(45)
Correct Answer:
False
The ____________________ manager is the default manager class for all content panes.
Free
(Short Answer)
4.7/5
(28)
Correct Answer:
BorderLayout
import javax.swing.*;
import java.awt.*;
public class JDemoGridLayout extends JFrame
{
private JButton b1 = new JButton("Button 1");
private JButton b2 = new JButton("Button 2");
private JButton b3 = new JButton("Button 3");
private JButton b4 = new JButton("Button 4");
private JButton b5 = new JButton("Button 5");
____________________________________________
private Container con = getContentPane();
public JDemoGridLayout()
{
con.setLayout(layout);
con.add(b1);
con.add(b2);
con.add(b3);
con.add(b4);
con.add(b5);
setSize(200, 200);
}
public static void main(String[] args)
{
JDemoGridLayout frame = new JDemoGridLayout();
frame.setVisible(true);
}
}
Using the above code, write the statement in the shaded line provided to establish a GridLayout with three horizontal rows and two vertical columns, with horizontal and vertical gaps of five pixels each.
(Essay)
4.8/5
(33)
A(n) ____ implements all methods in an interface and provides an empty body for each method.
(Multiple Choice)
5.0/5
(33)
The parent class for all event objects is named ____, which descends from the Object class.
(Multiple Choice)
5.0/5
(33)
import javax.swing.*;
import java.awt.*;
public class JDemoBorderLayout extends JFrame
{
private JButton nb = new JButton("North Button");
private JButton sb = new JButton("South Button");
private JButton eb = new JButton("East Button");
private JButton wb = new JButton("West Button");
private JButton cb = new JButton("Center Button");
private Container con = getContentPane();
public JDemoBorderLayout()
{
con.setLayout(new BorderLayout());
_________________________________________
_________________________________________
_________________________________________
_________________________________________
_________________________________________
setSize(400, 150);
}
public static void main(String[] args)
{
JDemoBorderLayout frame = new JDemoBorderLayout();
frame.setVisible(true);
}
}
Using the above code, write the statements in the shaded lines provided to add components to each of the five regions (north, south, east, west and center).
(Essay)
4.7/5
(35)
The FlowLayout class contains ____ constants you can use to align Components with a Container.
(Multiple Choice)
4.8/5
(38)
A ____ is placed at the top of a container and contains user options.
(Multiple Choice)
4.8/5
(38)
import java.awt.*;
import javax.swing.*;
import java.awt.Color;
public class JFrameWithColor extends JFrame
{
private final int SIZE = 180;
private Container con = getContentPane();
private JButton button =
new JButton("Press Me");
public JFrameWithColor()
{
super("Frame");
setSize(SIZE, SIZE);
con.setLayout(new FlowLayout());
con.add(button);
_____________________________________
_____________________________________
_____________________________________
}
public static void main(String[] args)
{
JFrameWithColor frame =
new JFrameWithColor();
frame.setVisible(true);
}
}
In the first shaded line provided, write the statement to set the background color of the JFrame's content pane to gray. Using the remaining two shaded lines, write the statements to set the JButton foreground color to white and the background color to blue.
(Essay)
4.9/5
(43)
When you type "A", two ____ key codes are generated: Shift and "a".
(Multiple Choice)
5.0/5
(37)
Match each term with the correct statement below.
-Use this class to greatly increase the number of possible component arrangements
(Multiple Choice)
4.9/5
(40)
Match each term with the correct statement below.
-Use when you need to add components into a grid of rows and columns; each component is the same size
(Multiple Choice)
4.8/5
(28)
Write the statement to set the background color of a button named goBtn to a color of green.
(Essay)
4.9/5
(39)
A common mistake when using BorderLayout is to add a Component to a content pane or frame without naming a region, resulting in some of the components not being visible.
(True/False)
4.8/5
(34)
If you wanted to see the x-coordinate of a user click, you would use the ____ method of the MouseEvent class.
(Multiple Choice)
4.9/5
(38)
Write the statement to establish a GridLayout with three horizontal rows and six vertical columns in a Container named myGrid.
(Essay)
4.8/5
(32)
Showing 1 - 20 of 69
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)