The long and short of it...
The AWT core starts a native "event loop". This loop basically takes in events from the OS and processes them. If the event is of interest to the current application context, the event is processed and added to the Event Queue.
The Event Queue is processed by the Event Dispatching Thread, which dispatches the event to the appropriate listener, based on who the event was for.
This is a significant simplification of the process.
None-the-less, when an event comes into the native "event loop", it's properties are inspected and an appropriate AWT Event is generated. How this is determined comes down a lot to how the OS passes it's event information, but basically, if the OS detects a drag, the MouseEvent
has it's ID
property set to MouseEvent.MOSUE_DRAGGED
, this allows the Component
to sift through the events and determine the best listener it should notify, which comes out to be MouseMotionListener.mouseDragged(MouseEvent)
For example, this is the processMouseMotionEvent
method take from Component
protected void processMouseMotionEvent(MouseEvent e) {
MouseMotionListener listener = mouseMotionListener;
if (listener != null) {
int id = e.getID();
switch(id) {
case MouseEvent.MOUSE_MOVED:
listener.mouseMoved(e);
break;
case MouseEvent.MOUSE_DRAGGED:
listener.mouseDragged(e);
break;
}
}
}