Chapter 5. Writing Event Listeners

 <  Day Day Up  >  

http://java.sun.com/docs/books/tutorial/uiswing/events/index.html

This chapter gives you details about writing event listeners. It assumes you've already read Handling Events (page 19) in Chapter 2, which gives an overview of the event model.

You might not need to read this section, at all. Your first source of information for event information should be the how-to section for the component in question. You can find the appropriate section using A Visual Index to Swing Components (page 37) in Chapter 3. Each component's section shows code for handling the events most commonly needed when implementing the component. For example, How to Use Check Boxes (page 163) in Chapter 7 shows you how to handle mouse clicks on check boxes using an item listener.

This chapter contains the following sections:

  • Some Event-Handling Examples includes programs which illustrate events and event handling.

  • General Information about Writing Event Listeners provides information that's useful for handling all types of events. One of the topics covers the use of adapters and inner classes to implement event handlers.

  • Listeners Supported by Swing Components is the place to find out which Swing components can fire which kinds of events. This section includes a handy quick-reference table.

  • Listener API Table features a comprehensive reference table that shows each listener, its adapter class, and its methods .

  • At the end of this chapter, the Summary reviews what we've covered and Questions and Exercises tests what you've learned in this chapter. Finally, Example Programs lists all the examples in this chapter and indicates where you can find them on the CD and online.

If you're having some hard-to-debug problems related to handling events, you may find the solutions in Solving Common Event-Handling Problems (page 739) in the Appendix.

Some Event-Handling Examples

Multiple Listeners Example

General Information about Writing Event Listeners

Design Considerations

Getting Event Information: Event Objects

Concepts: Low-Level Events and Semantic Events

Event Adapters

Inner Classes and Anonymous Inner Classes

The EventHandler Class

Listeners Supported by Swing Components

Listeners That All Swing Components Support

Other Listeners That Swing Components Support

Listener API Table

Summary

Questions and Exercises

Example Programs

 <  Day Day Up  >  


JFC Swing Tutorial, The. A Guide to Constructing GUIs
The JFC Swing Tutorial: A Guide to Constructing GUIs (2nd Edition)
ISBN: 0201914670
EAN: 2147483647
Year: 2004
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net