You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ReceiveAdapter.java 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package kommunikation.controller;
  7. import java.util.Observable;
  8. import java.util.Observer;
  9. import java.util.logging.Logger;
  10. import kommunikation.transmitter.BilderKom;
  11. import kommunikation.transmitter.Figur;
  12. import kommunikation.view.ViewChat;
  13. /**
  14. *
  15. * @author Alexander_Christoph
  16. */
  17. public class ReceiveAdapter implements Observer
  18. {
  19. ViewChat view;
  20. BilderKom model;
  21. Logger lg =Logger.getLogger("observer");
  22. public ReceiveAdapter(ViewChat view, BilderKom model)
  23. {
  24. this.view = view;
  25. this.model = model;
  26. }
  27. public void registerEvents()
  28. {
  29. model.addObserver(this);
  30. }
  31. @Override
  32. public void update(Observable arg0, Object arg1)
  33. {
  34. lg.info("in update");
  35. Object obj;
  36. obj = model.getNachricht();
  37. if(obj instanceof String)
  38. {
  39. String text = obj.toString() + "\n";
  40. view.getTaChat().append("Freund: " + text);
  41. }
  42. if(obj instanceof Figur)
  43. {
  44. model.addFigurFremd((Figur)obj); //muss eventuell noch gezeichnet werden nachdem es hinzugefügt wurde !!!
  45. view.repaint();
  46. }
  47. }
  48. }