import java.awt.*;
import java.awt.event.*;

class ModelControlerForInputPanel implements ActionListener {
    Model model;
    InputPanel container;

    ModelControlerForInputPanel(InputPanel container) {
	this.model = container.model;
	this.container = container;
    }

    public void actionPerformed(ActionEvent e) {
	TextField textfield = (TextField)e.getSource();
	try {
	    System.out.println("Event: " + e);
	    int i = Integer.parseInt(e.getActionCommand());
	    if (textfield.equals(container.textfield1)) {
		System.out.println("Setting to textfield1: " + i);
		model.setX(i);
	    }
	    else if (textfield.equals(container.textfield2)) {
		System.out.println("Setting to textfield2: " + i);
		model.setY(i);
	    }
	    else if (textfield.equals(container.textfield3)) {
		System.out.println("Setting to textfield2: " + i);
		model.setZ(i);
	    }
	    model.notifyObservers();
	} catch (NumberFormatException ne) {
	    container.update(model, null);
	}
    }
}
