-
Event Handling Question
Something about the AWT event model is puzzling me. Scenario: A button component
has registered an event listener (implementing a MouseAdapter, for instance).
Now, the Listener is implementing, say, two or three methods (mouseClicked,
mouseExit, etc.). When the mouse clicks on the button, or exits the button,
this "Event" is passed to the appropriate method implemented in the Listener
(then handled in some way).
All that is fine and dandy. But my questions...
What is actually generating the original event? I read things like, "The
AWT passes the event to the component(button)." If that is the case, and
the button isn't generating the event object, then what in the AWT is? Also,
once the event object exists, how does the button know which method in the
Listener to call? It's passing (or forwarding the event object) but how
does it know it should pass it to mouseClicked, or mouseExit, etc.?
Any help or explanation is greatly appreciated!
Ed
(note: also posted in AWT message board)
-
Re: Event Handling Question
"Edward" wrote:
>
>Something about the AWT event model is puzzling me. Scenario: A button
component
>has registered an event listener (implementing a MouseAdapter, for instance).
> Now, the Listener is implementing, say, two or three methods (mouseClicked,
>mouseExit, etc.). When the mouse clicks on the button, or exits the button,
>this "Event" is passed to the appropriate method implemented in the Listener
>(then handled in some way).
>
>All that is fine and dandy. But my questions...
>
>What is actually generating the original event? I read things like, "The
>AWT passes the event to the component(button)." If that is the case, and
>the button isn't generating the event object, then what in the AWT is?
Also,
>once the event object exists, how does the button know which method in the
>Listener to call? It's passing (or forwarding the event object) but how
>does it know it should pass it to mouseClicked, or mouseExit, etc.?
>
>Any help or explanation is greatly appreciated!
>
>Ed
>(note: also posted in AWT message board)
*Awt sends action event to button which is clicked
*for processing this event button has to be registered
*new Button().addButtonListener(this) will register button for this object
& passes its reference to awt
*functions like processActionEvent(java.awt.ActionEvent )
1)processes this event & dispatches to registered listener
2)invoked only when ActionListener object is registered or
ActionEvents are enabled by enableEvents
*Button object calls all methods in interface class 1 at a time
& thus do processing for all methods
*whatever methods u dont require u can give their body as blank
if u implement interface or either extend from adapter classes
& override only those methods u require & leave other to super class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks