Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the components of the java event handling mechanism

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to use the components of the java event handling mechanism". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to use the components of the java event handling mechanism.

1. Event, event object, describe the change of phase.

For example, click an action in GUI to start and stop containers in Spring Framework, such as computer startup, shutdown, hibernation, cache expiration, Wechat official account follow, customs clearance, and so on.

2. The event source can be any object and has the ability to trigger events.

Listeners are typically registered (or deactivated) in this object, where events are usually triggered. A source may produce many different types of events, registering listeners for different types of events, and each type of event can register one or more listeners.

3. Event listener, a class that implements a specific interface, needs to implement specific handling methods for specific events, and must be registered on specific events.

Example

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 informed)% s assigned homework"% s "\ n", this.name, teacher.getName (), arg) }} Thank you for your reading, the above is the content of "how to use the components of the java event handling mechanism". After the study of this article, I believe you have a deeper understanding of how to use the components of the java event handling mechanism, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report