Quiz

If your brain hasn't been turned into a GUI mush with this hour's toil, test your skills by answering the following questions.

Questions

1:Which user component is used as a container to hold other components?
  1. TupperWare

  2. JPanel

  3. Choice

2:Which of the following must be done first within a container?
  1. Establish a layout manager

  2. Add components

  3. Doesn't matter

3:What method determines how components will be arranged within a container?
  1. setLayout()

  2. setLayoutManager()

  3. setVisible()

Answers

A1: b. JPanel. You can add components to the panel, and then add the panel to another container such as a frame.
A2: a. You must specify the layout manager before the components so you can add them in the correct way.
A3: a. The setLayout() method takes one argument: the layout ...

Get SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH EDITION now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.