import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class Controller implements ActionListener { private IModel model; private IView view; public Controller(IModel m) { model = m; } public void setView(IView v) { view = v; } @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub switch (e.getActionCommand()) { //read from the input textfield case "Echo Button": String text = view.getInputString(); //send text to the model model.setString(text); //clear input textfield view.clearInputString(); //finally echo the string in view text = model.getString(); view.setEchoOutput(text); break; case "Exit Button": System.exit(0); break; } } }