Added WindowListener to  the main frame.