consider this class
:
public class mycomponent extends JComponent {
public mycomponent(){
addMouseMotionListener(new MouseMotionHandler());
}
class MouseMotionHandler implements MouseMotionListener{
public void mouseMoved(MouseEvent event){
//do something
}
public void mouseDragged(MouseEvent event){
//do something
}
}
}
Now Lets say a mouse drag event
occurs. How does the MouseMotionHandler
knows which method to call.
of the two methods implemented. Or how is the method to be called resolved in run-time when an event
occurs.
If the MouseEvent event
that gets passed to these method is MouseDrag Event
, how is that only mouseDragged
is called.
and how does it know that it is a MouseDrag
event and not MouseMove
event?