Java Listener principle

Source: Internet
Author: User
Tags event listener

Originally from: http://www.cnblogs.com/hulitut/archive/2012/03/27/2420414.html

The latest Java event handling method is to generate events based on the authorization event model event source and send it to one or more listener listeners simply by waiting until it receives an event. Once the event is accepted, the listener processes the events and then returns. Event: In the authorization event model, an event is an object that describes the state of the event source change.  events can be generated directly or indirectly through the mouse, keyboard, and GUI interfaces. such as: Press a button, enter a character through the keyboard, select an item in the list box, click a mouse, and so on. Event Source: Event Source is an object that generates events an event source may generate different types of event event sources providing a set of methods for registering one or more listeners for an event. Each type of event has its own method of registration. General form: public void Add<eventtype>listener (Typelistener e)
The event control process taken by AWT: The Listener object belongs to an instance of a class that implements a special interface, called the Listener interface event source, which is an object that registers one or more listener objects and sends them an event object. The event source sends an event object to all registered listeners when an event occurs.  Listener Objects Use the information in the event object to determine their response to an event model: 1. Agent-based (authorization) event model event handling is an event source that is authorized to one or more event listeners. The basic principle is that components fire events, event listeners listen and handle events, and the Add<eventtype>listener method of the component can be invoked to register listeners with the component. After adding it to the component, if the component fires the corresponding type of event, then the event-handling method defined in the listener is called. 2. This model consists mainly of three object-centric event sources that       are fired by it to generate events that    are objects that produce or throw events. The event listener  is used by it to handle events that          implement a particular EventListener interface that defines one or more methods that the event source calls to respond to each particular event type that the interface handles. Event  -specific event type    event types are encapsulated in a class hierarchy that is rooted in java.util.EventObject. When an event occurs, the event records all events that occurred and propagates from the event source to the Listener object

Java Listener principle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.