Lab 7 Objective In this lab we will learn about anonymous classes and how to implement them. We will use the anonymous classes the extend the window adapters. Background: Anonymous Classes # An anonymous class is a local class without a name. An anonymous class is defined and instantiated in a single succinct expression using the new operator. While a local class definition is a statement in a block of Java code, an anonymous class definition is an expression, which means that it can be included as part of a larger expression, such as a method call. When a local class is used only once, consider using anonymous class syntax, which places the definition and use of the class in exactly the same place. # One common use for an anonymous class is to provide a simple implementation of an adapter class. An adapter class is one that defines code that is invoked by some other object. Since the body of such a class is typically quite short, it is easy to define an adapter class as an anonymous class. # Because an anonymous class has no name, it is not possible to define a constructor for it within the class body. This is one of the basic restrictions on anonymous classes. # One of the most elegant things about anonymous classes is that they allow you to define a one-shot class exactly where it is needed. In addition, anonymous classes have a succinct syntax that reduces clutter in your code. # In addition to the normal closing brace, an anonymous class is closed by a close parenthesis and a semicolon - " }); " Assignment 1. Download the file lab7.java 2. Extend the Window Adapter and Component Adapter by adding the following anonymous classes to the ListeningFrame: WindowListener, WindowFocusListener, and ComponentListener. 3. Add the following methods to the WindowListener: windowClosing and windowOpening. 4. Add the following methods to the WindowFocusListener: windowGainedFocus and windowLostFocus. 5. Add the following methods to the ComponentListener: componentResized and componentMoved. Hints * windowClosing should display a message such as the following: JOptionPane.showMessageDialog(ListeningFrame.this, "I'll miss you."); when the window is closed * windowOpening should should change the shapeColor, get height and width, etc. * windowGainedFocus and windowLostFocus should both change the shapeColor so one can tell whther the window has focus or not. * componentResized should change the size of the shape within the frame. * componentMoved should check to see if the shape is still contained where the frame is has been moved to. Submission Please submit your lab using the following command: sendlab.215.3 7 lab7.java