Handle the paint event