Kaleb Pederson
Kaleb Pederson

Reputation: 46489

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

Most of the tutorials and documentation that 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?

Upvotes: 2

Views: 10254

Answers (2)

scoude
scoude

Reputation: 9

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É

Upvotes: 0

Tom Hawtin - tackline
Tom Hawtin - tackline

Reputation: 147154

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

Upvotes: 1

Related Questions