// the view displays a button and a text field; // it listens to the button and is a listener for model changes import javax.swing.*; import java.awt.*; import java.awt.event.*; // implementing the Semantics class View extends Layout implements IModelListener, ActionListener { IViewListener listener; View() { super(); but.addActionListener(this); } // update the label public void notifyListener(int c) { lab.setText(new Integer(c).toString()); } // ------------------------------------------- // add listener to View public void register(IViewListener vl) { listener = vl; } // inform the listener of an event public void actionPerformed(ActionEvent e) { listener.notifyListener(); } }