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-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

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

Development

Wechat

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

12
Report