Thibaud 8e81af87b1 [Shapes] Add shapes application
Merge commit '9bd4e3a87ca931af87c4d88b09f25fa1090eed38' as 'shapes'
2018-09-29 23:58:01 +02:00

35 lines
736 B
Java
Executable File

package fr.uha.graphics.ui;
import javax.swing.JPanel;
public abstract class View extends JPanel {
private Object model;
private Controller controller;
public View(Object model) {
this.model = model;
this.controller = defaultController(model);
this.controller.setView(this);
this.addMouseListener(this.controller);
this.addMouseMotionListener(this.controller);
this.addKeyListener(this.controller);
}
public void setModel(Object model) {
this.model = model;
this.controller.setModel(model);
}
public Object getModel() {
return this.model;
}
public Controller defaultController(Object model) {
return new Controller(model);
}
final public Controller getController() {
return this.controller;
}
}