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.

SendController.java 926B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 controller;
  7. import java.awt.event.ActionEvent;
  8. import java.awt.event.ActionListener;
  9. import model.Transmitter;
  10. import view.ChatView;
  11. /**
  12. *
  13. * @author Apollo
  14. */
  15. public class SendController implements ActionListener
  16. {
  17. ChatView view;
  18. Transmitter model;
  19. String input;
  20. public SendController(ChatView view,Transmitter model)
  21. {
  22. this.view = view;
  23. this.model = model;
  24. }
  25. public void registerEvents()
  26. {
  27. view.getInputField().addActionListener(this);
  28. }
  29. @Override
  30. public void actionPerformed(ActionEvent arg0)
  31. {
  32. input = view.getInputField().getText();
  33. view.getChatanzeige().append(input + "\n");
  34. view.getInputField().setText("");
  35. model.send(input);
  36. }
  37. }