Trail: Creating a GUI with JFC/Swing
Questions and Exercises: Learning Swing by Example

Questions

  1. On what thread should GUIs be created, to guarantee thread safety?

  2. Why should you be careful to minimize the time spent in event-handler code?

  3. What is the purpose of the setLabelFor method?

  4. What is the content pane?

  5. Describe the three code segments that must be implemented for an event handler.

  6. Which text component is best suited for controlling the format of a single line of user-entered text?

  7. What is lazy image loading and why would you use it?

Exercises

1. Write the code that creates a label displaying the following text, with the italics and font size as shown in this screenshot:

2. Convert the LunarPhases example to use radio buttons instead of a combo box.

3. Add a Show Dialog check box to the VoteDialog example so that the dialogs are shown only if this check box is selected.

Check your answers

Previous page: Summary
Next page: Using Swing Components