Thibaud 9bd4e3a87c Squashed 'shapes/' content from commit 0f9f944
git-subtree-dir: shapes
git-subtree-split: 0f9f944deb15275858fadb5e133a8d14e46a640f
2018-09-29 23:48:08 +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;
}
}