git-subtree-dir: shapes git-subtree-split: 0f9f944deb15275858fadb5e133a8d14e46a640f
35 lines
736 B
Java
Executable File
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;
|
|
}
|
|
}
|