Monitoring Mouse Events

In the next applet, we'll illustrate monitoring mouse events such as the mouse moving, entering, and exiting an applet. This particular applet—called EventMonitorApplet—also monitors mouse up and down events and prints information about each event. EventMonitorApplet extends the Applet class (as do all applets). It includes an EventPrinter class that checks to see if an event is a mouse event, and if so, its print method prints which mouse event occurred. The EventMonitorApplet includes an instance of EventPrinter that is both public and static. It is public because both EventMonitor and EventPrinter classes use it. It is static because only one EventPrinter is required. Note that this applet is set up just like the

Get Graphic Java™ 1.2, Volume I: AWT, Third 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.