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.

CommandInvoker.java 650B

12345678910111213141516171819202122232425262728293031323334
  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 kontakte.controller;
  7. import java.awt.Component;
  8. import java.util.HashMap;
  9. /**
  10. *
  11. * @author nobody
  12. */
  13. public class CommandInvoker
  14. {
  15. private HashMap<Component, CommandInterface> commands;
  16. public CommandInvoker()
  17. {
  18. commands = new HashMap<>();
  19. }
  20. public void addCommand(Component key, CommandInterface value)
  21. {
  22. commands.put(key, value);
  23. }
  24. public void executeCommand(Component key)
  25. {
  26. commands.get(key).execute();
  27. }
  28. }