Your MouseMotionListener
in the inside
is generating a new event. That event will be caught again by the very same MouseMotionListener
, creating an endless loop. Since you are creating an event when the previous one is still unfinished, they will stack up until a StackOverflowError
explodes your application.
Your second code does not have this problem because the inside
delegates to the outside
and it finishes there.