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?
posted 9 years ago
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.