What are Listeners and Event sources? Explain at least five Listener interfaces and Event Sources briefly.
Event sources
Almost all GUI components except few exceptions generate one or more types of events. The table below lists some of the event sources that can generate events.
An event source must be registered into listeners in order for the listeners to receive notifications about a specific type of event. We use addTypeListener(TypeListener el) method for this registration. Here, Type is the name of the event, and el is a reference to the event listener. For example, the method that registers a keyboard event listener is called addKey Listener().
EVENT LISTENER INTERFACES
To handle events we must implement event listener interfaces. It has two major requirements. First, it must have been registered with one or more sources to receive notifications about specific types of events. Second, it must implement methods to receive and process these notifications. The event listener interfaces and their corresponding method declarations are given below.
Comments
Post a Comment