creation: 3/24/99; revisions: 6/24/99, 01/26/00

CHAPTER 57 --- Adding GUI Components to a Containter

The previous chapters have introduced event-driven programing and the three parts of a GUI application:

  1. Components that make up the Graphical User Interface.
    • Container classes that hold other components.
      • Windows and Frames
    • Components held inside container classes.
      • Buttons, text fields, and others.

  2. Listeners that receive the events and respond to them.
    • Each event type for which a response is expected must have a listener.
    • A listener object must be registered with the GUI component that generates that event (or with a component that contains it.)
    • A listener object can be registered with several components if it is written to handle their events.

  3. Application code that does useful work for the user.
This chapter discusses how to add button components to a frame and how to register a listener for button events.

Chapter Topics:

  • Adding Buttons to a Frame.
  • Layout managers.
  • Action listeners.
  • Registering a listener with a GUI component.
  • Changing the background color of a frame.
  • actionPerformed() method
  • Using actionPerformed() with several buttons.

QUESTION 1:

(Review: ) What is a container class?

Click Here after you have answered the question