Google for "writing a MouseListener".