How to use the components of the java event handling mechanism
This article introduces the knowledge about "how to use java event handling mechanism components". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
1. Event, event object, describes the change of phase.
For example, click an action in the GUI to start and stop containers in the Spring Framework, such as computer startup, shutdown, hibernation, cache expiration, WeChat official account attention, take off, etc.
The event source can be any object with the ability to trigger events.
Listeners are typically registered (or deactivated) in this object, where the triggering of events usually occurs. A single source may generate many different types of events, register listeners for different types of events, and register one or more listeners for each type of event.
Event listener, a class that implements a specific interface, needs to implement a specific processing method for a specific event, and must be registered on a specific event.
examples
package event; import java.util.Observable; /** * Created by Joe on 2018/4/11 */public class Student implements java.util.Observer { private String name; public Student(String name) { this.name = name; } @Override public void update(Observable o, Object arg) { Teacher teacher = (Teacher) o; System.out.printf("Student %s observed (actually notified) %s assigned assignment" %s "\n", this.name, teacher.getName(), arg); }}"How to use Java event handling mechanism components" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!