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.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
  3. * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
  4. */
  5. package ChatProgramm.controller.commands;
  6. import ChatProgramm.model.Client;
  7. import ChatProgramm.model.Server;
  8. import ChatProgramm.model.TransmitterInterface;
  9. import ChatProgramm.util.OhmLogger;
  10. import ChatProgramm.view.ChatView;
  11. import java.util.logging.Logger;
  12. import javax.swing.JTextField;
  13. import ChatProgramm.model.Nachricht;
  14. /**
  15. *
  16. * @author ahren
  17. */
  18. public class CommandSend implements CommandInterface
  19. {
  20. private static Logger lg = OhmLogger.getLogger();
  21. private JTextField eingabeFeld;
  22. private String nachricht;
  23. private ChatView view;
  24. public TransmitterInterface transmitterInterface;
  25. public Server server;
  26. public Client client;
  27. public CommandSend(ChatView view)
  28. {
  29. this.view = view;
  30. this.eingabeFeld = view.getTfNachricht();
  31. transmitterInterface = null;
  32. }
  33. @Override
  34. public void execute()
  35. {
  36. if(transmitterInterface != null && !eingabeFeld.getText().isEmpty()){
  37. transmitterInterface.send(eingabeFeld.getText());
  38. eingabeFeld.setText("");
  39. }
  40. }
  41. @Override
  42. public boolean isUndoable()
  43. {
  44. return false;
  45. }
  46. @Override
  47. public void undo()
  48. {
  49. }
  50. }