Press any key to spawn a new ball; click on a ball to delete it

This sample demonstrates how useful multiple event handlers can be. Each ball has its own draw and click handlers; there is no single global handler that draws all the balls and detects mouse clicks on them. Each ball is solely responsible for its own behavior.

Source code