开发者

java.awt.Component.dispatchEvent()'s purpose and behavior

开发者 https://www.devze.com 2022-12-17 19:45 出处:网络
Most of the tutorials and documentation 开发者_如何学JAVAthat I\'ve been reading seem to indicate that most component communication takes place by subscription using listeners.

Most of the tutorials and documentation 开发者_如何学JAVAthat I've been reading seem to indicate that most component communication takes place by subscription using listeners.

The Java docs indicate that java.awt.Component#dispatchEvent(AWTEvent e):

Dispatches an event to this component or one of its sub components. Calls processEvent before returning for 1.1-style events which have been enabled for the Component.

Given that listeners seem commonplace, what is the purpose of dispatchEvent and how / where is the dispatched event received?


The component has to receive the events to dispatch somewhere. This is where a component receives the events. The events come from the EventQueue.


I researched how to send custom events to a JFrame, and finally I succeeded in compiling some examples found on the web.

The functional result is visible here:

link text

Hoping that it might be useful!

Serge COUDÉ

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号