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.

CommandController.java 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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;
  6. import ChatProgramm.controller.commands.CommandConnect;
  7. import ChatProgramm.controller.commands.CommandInvoker;
  8. import ChatProgramm.controller.commands.CommandSend;
  9. import ChatProgramm.view.ChatView;
  10. import java.awt.Component;
  11. import java.awt.event.ActionEvent;
  12. import java.awt.event.ActionListener;
  13. /**
  14. *
  15. * @author ahren
  16. */
  17. public class CommandController implements ActionListener{
  18. private ChatView view;
  19. private CommandInvoker invoker;
  20. public CommandController(ChatView view){
  21. this.view = view;
  22. this.invoker = new CommandInvoker();
  23. }
  24. public void registerEvents(){
  25. view.getBtnConnect().addActionListener(this);
  26. //ToDo: muss auf gFrame referenzieren
  27. //view.getTfNachricht().addActionListener(this);
  28. }
  29. public void registerCommands(){
  30. CommandSend commandSend = new CommandSend(view);
  31. invoker.addCommand(view.getBtnConnect(), new CommandConnect(view, commandSend));
  32. //invoker.addCommand(view.getTfNachricht(), commandSend);
  33. }
  34. /**
  35. * Ausführen des jeweiligen Kommandos
  36. * @param e Referenz auf das Event
  37. */
  38. @Override
  39. public void actionPerformed(ActionEvent e) {
  40. Component key = (Component)e.getSource();
  41. invoker.executeCommand(key);
  42. // if(key == view.getBtnOpen()|| key==view.getMiOpen())
  43. // invoker.deleteStack();
  44. // }
  45. }
  46. }