Java event drive depth adventure

xiaoxiao2021-03-05  48

Personally, the listening and processing of events in Java is better. And the perfection of its structure is not described in terms of language. In Java, the use of the interface can be said to represent a person's understanding and master of Java. And those so-called patterns are almost all interfaces. When I am watching the mode, often spend the most time is the application of the interface. The interface makes security enhances a class function, and provides an abstract skeleton implementation. However, not all of the interfaces have skeletons, some is an interface, the rest is comment, what is the use of such an interface? If you are more familiar with Java, I believe that you have already met some empty interfaces, such as the cloneable interface, it is nothing more than the object to be copied. Without this interface, your program is destined to be throw Exception. Today, when I saw the Java event driver, I met an empty interface type EventListener. Now there is an idea, is it the most basic Java type to be empty interface? I have time to look at the program.

The event-driven format in Java is generally add *** listener (), remove *** listener (). I don't care how to generate these events when I write code. Think now, each event must have an event source, that is, EventSource, its role is to generate *** changeeevent, here EventListener must be that every event event is implemented, saying that it is just imports or Extends can be, these don't worry, Sun has long been doing these code, we can view, here if you write a big system, it is inevitable to rewote an event. The driver code, but refer to this set of Sun We can easily implement your own event release, listening, processing, etc. Event can be provided by Sun, the release of the event may be rewritten, but if you read the Sun's code carefully, we can easily find the code source PropertyChangeEvent. Here's An Overview of How Event Handling In The AWT WORKS.

A Listener Object Is An Instance of a Class That Implements A Special Interface Called (NATURALLY ENOUGH) A listener interface.

An Event Source Is An Object That Can Register Listener Objects and Send Them Event Objects.

Information.

转载请注明原文地址:https://www.9cbs.com/read-34578.html

New Post(0)