my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes Event Handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Event Handling" Watch "Event Handling" New topic

Event Handling

kedar parundekar
Ranch Hand

Joined: May 10, 2006
Posts: 40
I know,
1)The underlying OS is constantly monitoring events
2)When a event occurs, the OS reports these events to the programs that are running.

Q)How OS reports these events to programs that are running? Is there any OS event also?
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38045
If I remember correctly the devices (eg mouse, keyboard) send messages whenever their state changes; these are called interrupts, and they are handled by hardware using a device called an exception handler, which does not mean the same as the term in Java programming.

Presumably somehow the OS tells the JVM that there has been an event at pixel no (500, 400) and it was a mouse click. The JVM then works out from its position that it was in the area occupied by your exitButton, and exitButton then sends an ActionEvent to whichever Listener(s) is(are) registered to it. The Listener then receives the ActionEvent into its actionPerformed() method, and you know the rest.

Anybody able to give a better explanation???

I agree. Here's the link:
subject: Event Handling
Similar Threads
What happens to events when an actionlistener is hogging the event dispatch thread
JBoss Drools - Drools Fusion: Appropriate Approach ?
Performance Analysis
JBoss Drools: Drools Fusion - Appropriate choice?
64 Vs 32 bit Windows