Package break_out.controller
Class Controller
- java.lang.Object
-
- break_out.controller.Controller
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.KeyListener
,java.util.EventListener
public class Controller extends java.lang.Object implements java.awt.event.ActionListener, java.awt.event.KeyListener
The controller takes care of the input events and reacts on those events by manipulating the view and updates the model.- Author:
- dmlux, modified by I. Schumacher and I. Traupe, modified by Gruppe 175 (Moritz Henseleit, Ruben Meyer)
-
-
Constructor Summary
Constructors Constructor Description Controller(View view)
The constructor expects a view to construct itself.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent e)
If the user clicks any button this ActionListener will get called.private void
assignActionListener()
The controller gets all buttons out of the view with this method and adds this controller as an action listener.private void
assignKeyListener()
With this method the controller adds himself as a KeyListener.void
keyPressed(java.awt.event.KeyEvent e)
This method will be called, after a key was pressed down.void
keyReleased(java.awt.event.KeyEvent e)
This method will be called, after a key was released.void
keyTyped(java.awt.event.KeyEvent e)
This method will be called, after a key was typed.void
toPlayground()
This method switches the view to the FieldView which will display the playground.void
toStartScreen()
This method switches the view to the StartScreen view.
-
-
-
Constructor Detail
-
Controller
public Controller(View view)
The constructor expects a view to construct itself.- Parameters:
view
- The view that is connected to this controller
-
-
Method Detail
-
assignActionListener
private void assignActionListener()
The controller gets all buttons out of the view with this method and adds this controller as an action listener. Every time the user pushed a button the action listener (this controller) gets an action event.
-
assignKeyListener
private void assignKeyListener()
With this method the controller adds himself as a KeyListener. Every time the user pushed a key the KeyListener (this controller) gets an KeyEvent.
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
If the user clicks any button this ActionListener will get called. The method will get an ActionEvent e which held the source of this event.- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
-
keyTyped
public void keyTyped(java.awt.event.KeyEvent e)
This method will be called, after a key was typed. This means, that the key was pressed and released, before this method get called.- Specified by:
keyTyped
in interfacejava.awt.event.KeyListener
- Parameters:
e
- The key event
-
keyPressed
public void keyPressed(java.awt.event.KeyEvent e)
This method will be called, after a key was pressed down.- Specified by:
keyPressed
in interfacejava.awt.event.KeyListener
- Parameters:
e
- The key event
-
keyReleased
public void keyReleased(java.awt.event.KeyEvent e)
This method will be called, after a key was released.- Specified by:
keyReleased
in interfacejava.awt.event.KeyListener
- Parameters:
e
- The key event
-
toStartScreen
public void toStartScreen()
This method switches the view to the StartScreen view.
-
toPlayground
public void toPlayground()
This method switches the view to the FieldView which will display the playground.
-
-