Observer pattern and violation of Single Principality Rule
- by Devil Jin
I have an applet which repaints itself once the text has changed
Design 1:
//MyApplet.java
public class MyApplet extends Applet implements Listener{
private DynamicText text = null;
public void init(){
text = new DynamicText("Welcome");
}
public void paint(Graphics g){
g.drawString(text.getText(), 50, 30);
}
…