CHAPTER 57 --- Adding GUI Components to a Containter
The previous chapters have introduced
event-driven programing
and the three parts of a GUI application:
- Components that make up the Graphical User Interface.
- Container classes that hold other components.
- Components held inside container classes.
- Buttons, text fields, and others.
- 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.
- 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.
|