Implementing the frame event handlers.