文档

Java™ 教程-Java Tutorials 中文版
编写事件监听器
Trail: Creating a GUI With JFC/Swing

课程:编写事件监听器

Examples Index

This lesson gives you details about writing event listeners. You might not need to read this section. Your first source of information for event should be the how-to section for the component in question. Each component's section shows code for handling the events most commonly needed when implementing the component. For example, How to Use Check Boxes shows you how to handle mouse clicks on check boxes using an item listener.

Some Simple Event-Handling Examples

The programs in this section illustrate events and event handling.

关于编写事件监听器的一般信息

This section provides information that is useful for handling all types of events. One of the topics includes information on using adapters and inner classes to implement event handlers.

Swing 组件支持的监听器

This is the place to find out which Swing components can fire which kinds of events. You might want to bookmark this section so you can easily find its quick-reference table.

为常见事件实现监听器

This section has detailed information and examples of writing each common kind of event listener.

监听器 API 表

This section features a quick-reference table that shows each listener, its adapter class (if any), and its methods.

解决常见的事件处理问题

If you are having some hard-to-debug problems related to handling events, you might find the solution here.

问题和练习

Try these questions and exercises to test what you have learned in this lesson.

If you are interested in using JavaFX to create your GUI, see Handling JavaFX Events.


Previous page: Previous Lesson
Next page: Introduction to Event Listeners