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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.