11.6. Behind the Scenes: Low-Level Event Processing

When a component receives an event, that event gets passed to a method called processXxxEvent, where Xxx is Mouse (i.e., the method is called processMouseEvent), Key, Focus, Action, and so forth. For a summary, see Table 11.2 at the end of this section. The processXxxEvent method passes the event on to each of the attached listeners. In most cases, you just want to add listeners and don't care about the behind-the-scenes method. Occasionally, however, you may want to use these methods directly. For example, if you want to perform the same action for each of the possible mouse events, it is shorter to use processMouseEvent than to override all five methods of the MouseListener interface. If you ...

Get Core Web Programming, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.