package controller; import view.*; import java.awt.event.*; /** * The controller that instantiates a concrete IView2World object and connects * the world outside of Frame3 (the view) to Frame3. * The concrete adapter is implemented as an anonymous inner classe. */ public class Frame3Controller { public void constructFrame() { final Frame3 frame = new Frame3("View and Controller"); /** * A concrete anonymous IView2World class is installed in frame, without * frame knowing what it does. */ frame.addV2WAdapter(new IView2World() { public Object button1Clicked (ActionEvent e) { System.out.println("Responding to the clicking of button1:"); System.out.println(e); return null; } public Object button2Clicked (ActionEvent e) { System.out.println("Responding to the clicking of button2:"); System.out.println(e); return null; } }); frame.setVisible(true); } }