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.

StartStopController.java 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 wuerfel.controller;
  7. import java.awt.event.ActionEvent;
  8. import java.awt.event.ActionListener;
  9. import wuerfel.model.WuerfelModel;
  10. import wuerfel.view.WuerfelView;
  11. /**
  12. *
  13. * @author leo
  14. */
  15. public class StartStopController implements ActionListener
  16. {
  17. private WuerfelView view;
  18. private WuerfelModel model;
  19. public StartStopController(WuerfelView view, WuerfelModel model)
  20. {
  21. this.view = view;
  22. this.model = model;
  23. }
  24. public void registerEvents()
  25. {
  26. view.getBtnStart().addActionListener(this);
  27. view.getBtnStop().addActionListener(this);
  28. }
  29. @Override
  30. public void actionPerformed(ActionEvent e)
  31. {
  32. if (e.getSource() == view.getBtnStart())
  33. {
  34. model.start();
  35. }
  36. else
  37. {
  38. model.stop();
  39. }
  40. }
  41. }