Permalink
Browse files

Change WordInputCOmponent to an Actionlistener

  • Loading branch information...
1 parent a945566 commit 7379445b9ba49543f8570b1f6d19958377e60335 @KroneckerDelta KroneckerDelta committed Jan 27, 2014
@@ -15,9 +15,7 @@ public CrossWordController(InputView view, CrosswordGame crosswordGame) {
public void start() {
- WordInputComponent inputWordComponent = new WordInputComponent(view,
- crosswordGame);
- inputWordComponent.combineView2game();
+ view.addActionForSubmit(new WordInputActionListener(view, crosswordGame));
view.getInputView().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
view.getInputView().setVisible(true);
@@ -0,0 +1,25 @@
+package de.schauderhaft.architecture.example;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+public class WordInputActionListener implements ActionListener {
+
+ InputView view;
+ CrosswordGame game;
+
+ public WordInputActionListener(InputView view, CrosswordGame game) {
+ super();
+ this.view = view;
+ this.game = game;
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ String word = view.getInput().trim();
+ int points = game.submit(word);
+ view.newScore(points);
+
+ }
+
+}
@@ -1,30 +0,0 @@
-package de.schauderhaft.architecture.example;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-public class WordInputComponent {
-
- InputView view;
- CrosswordGame game;
-
- public WordInputComponent(InputView view, CrosswordGame game) {
- super();
- this.view = view;
- this.game = game;
- }
-
- public void combineView2game() {
-
- view.addActionForSubmit(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- String word = view.getInput().trim();
- int points = game.submit(word);
- view.newScore(points);
- }
- });
- }
-
-}

0 comments on commit 7379445

Please sign in to comment.