|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
- package kommunikation.controller;
-
- import java.util.Observable;
- import java.util.Observer;
- import java.util.logging.Logger;
- import kommunikation.transmitter.BilderKom;
- import kommunikation.transmitter.Figur;
- import kommunikation.view.ViewChat;
-
- /**
- *
- * @author Alexander_Christoph
- */
- public class ReceiveAdapter implements Observer
- {
- ViewChat view;
- BilderKom model;
- Logger lg =Logger.getLogger("observer");
-
- public ReceiveAdapter(ViewChat view, BilderKom model)
- {
- this.view = view;
- this.model = model;
- }
-
- public void registerEvents()
- {
- model.addObserver(this);
- }
-
- @Override
- public void update(Observable arg0, Object arg1)
- {
- lg.info("in update");
- Object obj;
- obj = model.getNachricht();
- if(obj instanceof String)
- {
-
- String text = obj.toString() + "\n";
- view.getTaChat().append("Freund: " + text);
- }
- if(obj instanceof Figur)
- {
- model.addFigurFremd((Figur)obj); //muss eventuell noch gezeichnet werden nachdem es hinzugefügt wurde !!!
- view.repaint();
- }
- }
-
- }
-
-
|