aspose file tools*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Event Handling" Watch "Event Handling" New topic
Author

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
Sheriff

Joined: Oct 13, 2005
Posts: 38412
    
  23
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???

CR
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Event Handling