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.

CommandSend.java 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 chatProg.controller;
  7. import java.awt.event.ActionEvent;
  8. import java.awt.event.ActionListener;
  9. import java.util.logging.Logger;
  10. import chatProg.logger.OhmLogger;
  11. import chatProg.model.ChatModel;
  12. import chatProg.view.ChatView;
  13. /**
  14. *
  15. * @author hd, christ
  16. */
  17. public class CommandSend implements ActionListener
  18. {
  19. private static Logger lg = OhmLogger.getLogger();
  20. ChatView view;
  21. ChatModel model;
  22. public CommandSend(ChatView view, ChatModel model)
  23. {
  24. this.view = view;
  25. this.model = model;
  26. }
  27. public void registerEvents(){
  28. view.getBtnSend().addActionListener(this);
  29. }
  30. @Override
  31. public void actionPerformed(ActionEvent e)
  32. {
  33. Object src = e.getSource();
  34. if(src == view.getBtnSend()){
  35. String msg = view.getTxtField().getText();
  36. if(msg != ""){
  37. model.sendMessage(msg);
  38. view.getLblStatusDialog().setText("Nachricht gesendet");
  39. view.getjTextArea().append("Ich: " + msg +"\n");
  40. }
  41. view.getTxtField().setText("");
  42. }
  43. }
  44. }