O'Reilly logo

Developing Java Beans by Robert Englander

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Events in the AWT Package

The components in the java.awt package use the same event model that I’ve just described. Many of the components in the package send event notifications for things such as mouse clicks, button presses, and window resizings. There are a number of standard classes and interfaces available in java.awt.event for dealing with such events and event notifications. It’s interesting to take a look at some of these more closely to see how they are used and how they behave. This will give you some more insight into how the event model works, and how it is employed by one of the core Java packages.

java.awt.Component is the base class for many components in the AWT package. It provides a great deal of functionality that is shared by all components. As such, there are also a number of events that are fired by all components. These events are grouped into a number of event-listener interfaces, which provide methods that are invoked when their associated events occur. Each of these interfaces extends java.util.EventListener. For each of these event-listener interfaces, there is also an event object class used to encapsulate any specific information related to an instance of the event. These event classes all extend the class java.awt.AWTEvent, which is a subclass of java.util.EventObject.

Let’s take a look at one of the event interfaces supported by the java.awt.Component class. This interface, java.awt.event.MouseListener , is used to provide notifications of events ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required