Exam 15: Advanced Gui Topics

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

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:
Verified

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:
Verified

False

The ____________________ manager is the default manager class for all content panes.

Free
(Short Answer)
4.7/5
(28)
Correct Answer:
Verified

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)

Describe the difference between an ActionEvent and a MouseEvent.

(Essay)
4.8/5
(36)

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)

The Color class contains ____ predefined color constants.

(Multiple Choice)
4.9/5
(36)

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)

When do you need to worry about using the getContentPane() method?

(Essay)
4.8/5
(35)
Showing 1 - 20 of 69
close modal

Filters

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