- However regardless of which event handling
methodology you use, the origin of events is still the same
- When a user presses and releases the
mouse button over a widget like a button, the windowing system
of the computer is notified that the mouse button was pressed
and released.
- The windowing system determines which window the
mouse was pressed over. If it is your program's window, it sends the
mouse event to your program. However, the windowing system only knows
about top level windows. It does not know anything about java controls,
dialogs, or buttons. Thus the windowing system notifies your program
and lets your program handle things from there.
- It's then your program's job to determine
what components are notified of the event.
- If the mouse is pressed
and released over an OK button for example, the program sends
mouse-down and mouse-up events to the OK button object. The button
looks at these events and determines if it should generate its own
event in response. Thus, if the user clicked on the "clickable" area,
the button, the button will generate its own "action event" which is
the event that you want to handle to perform an action when
the OK button is pressed.
Previous Page |
Next Page
|