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
Match each term with the correct statement below.
-Use when you need to set size, placement, and alignment constraints for every component that you add
(Multiple Choice)
4.8/5
(82)
The following statement produces a dark purple color that has green and blue components, but no red:
Color darkPurple = new Color(100, 0, 100);
(True/False)
4.8/5
(70)
A(n) _________________________ is a tree of components that has a top-level container as its root (that is, at its uppermost level).
(Short Answer)
4.9/5
(89)
Which of the following statements will correctly add a JMenuBar named myBar to a JFrame?
(Multiple Choice)
4.8/5
(83)
Match each term with the correct statement below.
-A key that does not generate a character, such as a function key
(Multiple Choice)
4.8/5
(74)
Any component you place on the screen has a vertical, or x-axis, position as well as a horizontal, or y-axis, position in the window.
(True/False)
4.9/5
(85)
With ____, a redrawn JPanel is displayed only when it is complete; this provides the viewer with updated screens that do not flicker while being redrawn.
(Multiple Choice)
4.7/5
(75)
To force the display of a scroll bar, you can use class variables defined in the ScrollPaneConstants class. What are they?
(Essay)
4.8/5
(71)
Describe the way in which components expand to fill their layout areas in FlowLayout and BorderLayout.
(Essay)
4.9/5
(72)
How would you arrange columns into equal rows and columns? Provide an example.
(Essay)
4.9/5
(79)
Using a FlowLayout object named myLayout, write the statement to set the layout of a content pane to left.
(Essay)
4.8/5
(74)
The state of a JCheckBoxMenuItem or JRadioButtonMenuItem can be determined with the ____ method.
(Multiple Choice)
4.7/5
(89)
If you do not specify alignment, Components are right-aligned in a FlowLayout Container by default.
(True/False)
4.9/5
(69)
Match each term with the correct statement below.
-Resides above the content pane
(Multiple Choice)
4.9/5
(87)
The JMenus are added to the JMenuBar using the ____ method.
(Multiple Choice)
4.7/5
(87)
You use the getModifiers() method with an InputEvent object, and you can assign the return value to a(n) ____ variable.
(Multiple Choice)
4.9/5
(71)
Which of the following statements will set the background color of a button named stop to a color of red?
(Multiple Choice)
4.8/5
(61)
import java.awt.*;
import javax.swing.*;
import java.awt.Color;
public class Checkerboard extends JFrame
{
private final int ROWS = 8;
private final int COLS = 8;
private final int GAP = 2;
private final int NUM = ROWS * COLS;
private int x;
private JPanel pane = new JPanel
(new GridLayout(ROWS, COLS, GAP, GAP));
private JPanel[] panel = new JPanel[NUM];
private Color color1 = Color.WHITE;
private Color color2 = Color.BLUE;
private Color tempColor;
public Checkerboard()
{
super("Checkerboard");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
add(pane);
for(x = 0; x < NUM; ++x)
{
panel[x] = new JPanel();
pane.add(panel[x]);
if(x % COLS == 0)
{
tempColor = color1;
color1 = color2;
color2 = tempColor;
}
if(x % 2 == 0)
panel[x].setBackground(color1);
else
panel[x].setBackground(color2);
}
}
public static void main(String[] args)
{
Checkerboard frame = new Checkerboard();
final int SIZE = 300;
frame.setSize(SIZE, SIZE);
frame.setVisible(true);
}
}
The above code creates a loop to fill even-positioned squares with one color and odd-positioned squares with another color, resulting in a checkerboard pattern. Describe how JPanels and a GridLayout are used to achieve this effect.
(Essay)
4.8/5
(79)
Showing 21 - 40 of 69
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)