aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiederick de Vries <diederick@diederickdevries.net>2020-03-27 17:53:37 +0100
committerDiederick de Vries <diederick@diederickdevries.net>2020-03-27 17:53:37 +0100
commit0ed13c787826ede3587d923d7a92f21dbd46aa8d (patch)
tree946c85463786eccfa3dbfcd971b0ae8875bf3961
parenta7a23e9a88f4ad40b8cc0398e14420b54be00d2e (diff)
downloadcalcusaurus-feat/no-text-in-numberfield.tar.gz
calcusaurus-feat/no-text-in-numberfield.tar.bz2
calcusaurus-feat/no-text-in-numberfield.zip
feature(view): add populated input verifier to exercise fieldfeat/no-text-in-numberfield
-rw-r--r--src/main/java/net/diederickdevries/calcusaurus/view/AssignmentPanel.java7
-rw-r--r--src/main/java/net/diederickdevries/calcusaurus/view/CalcusaurusFrame.java7
2 files changed, 9 insertions, 5 deletions
diff --git a/src/main/java/net/diederickdevries/calcusaurus/view/AssignmentPanel.java b/src/main/java/net/diederickdevries/calcusaurus/view/AssignmentPanel.java
index d3cb4e9..73b0abf 100644
--- a/src/main/java/net/diederickdevries/calcusaurus/view/AssignmentPanel.java
+++ b/src/main/java/net/diederickdevries/calcusaurus/view/AssignmentPanel.java
@@ -19,6 +19,7 @@ package net.diederickdevries.calcusaurus.view;
19 19
20import java.awt.Color; 20import java.awt.Color;
21import java.awt.event.ActionListener; 21import java.awt.event.ActionListener;
22import javax.swing.InputVerifier;
22import net.diederickdevries.calcusaurus.model.Assignment; 23import net.diederickdevries.calcusaurus.model.Assignment;
23import net.diederickdevries.calcusaurus.util.RequestFocusListener; 24import net.diederickdevries.calcusaurus.util.RequestFocusListener;
24 25
@@ -31,18 +32,20 @@ public final class AssignmentPanel extends javax.swing.JPanel
31 /** 32 /**
32 * Creates new form AssignmentPanel 33 * Creates new form AssignmentPanel
33 * 34 *
34 * @param assignment 35 * @param assignment The
35 * @param actionListener 36 * @param actionListener
37 * @param inputVerifier
36 * 38 *
37 * TODO: Get focus 39 * TODO: Get focus
38 */ 40 */
39 public AssignmentPanel(final Assignment assignment, ActionListener actionListener) 41 public AssignmentPanel(final Assignment assignment, final ActionListener actionListener, final InputVerifier inputVerifier)
40 { 42 {
41 initComponents(); 43 initComponents();
42 this.setBackground(new Color(0, 0, 0, 0)); 44 this.setBackground(new Color(0, 0, 0, 0));
43 label.setText("Wat is " + assignment.getAssignment() + "?"); 45 label.setText("Wat is " + assignment.getAssignment() + "?");
44 responseTextField.addActionListener(actionListener); 46 responseTextField.addActionListener(actionListener);
45 responseTextField.addAncestorListener(new RequestFocusListener()); 47 responseTextField.addAncestorListener(new RequestFocusListener());
48 responseTextField.setInputVerifier(inputVerifier);
46 } 49 }
47 50
48 public String getResponse() 51 public String getResponse()
diff --git a/src/main/java/net/diederickdevries/calcusaurus/view/CalcusaurusFrame.java b/src/main/java/net/diederickdevries/calcusaurus/view/CalcusaurusFrame.java
index 9585814..14a8204 100644
--- a/src/main/java/net/diederickdevries/calcusaurus/view/CalcusaurusFrame.java
+++ b/src/main/java/net/diederickdevries/calcusaurus/view/CalcusaurusFrame.java
@@ -28,11 +28,11 @@ import java.util.concurrent.Semaphore;
28import java.util.logging.Level; 28import java.util.logging.Level;
29import java.util.logging.Logger; 29import java.util.logging.Logger;
30import javax.swing.JButton; 30import javax.swing.JButton;
31import javax.swing.JFrame;
32import javax.swing.JTextField; 31import javax.swing.JTextField;
33import net.diederickdevries.calcusaurus.model.Assignment; 32import net.diederickdevries.calcusaurus.model.Assignment;
34import net.diederickdevries.calcusaurus.service.ExerciseService; 33import net.diederickdevries.calcusaurus.service.ExerciseService;
35import net.diederickdevries.calcusaurus.util.NumberUtil; 34import net.diederickdevries.calcusaurus.util.NumberUtil;
35import net.diederickdevries.calcusaurus.view.inputverifier.ExerciseInputVerifier;
36 36
37/** 37/**
38 * 38 *
@@ -50,7 +50,7 @@ public final class CalcusaurusFrame extends javax.swing.JFrame
50 50
51 private SelectionPanel selectionPanel; 51 private SelectionPanel selectionPanel;
52 private List<String> selection; 52 private List<String> selection;
53 53
54 /** 54 /**
55 * Creates new form RekenenFrame 55 * Creates new form RekenenFrame
56 */ 56 */
@@ -182,7 +182,8 @@ public final class CalcusaurusFrame extends javax.swing.JFrame
182 showAnswerWrong(assignment); 182 showAnswerWrong(assignment);
183 } 183 }
184 } 184 }
185 }); 185 }, new ExerciseInputVerifier(assignment.getInputVerification()));
186
186 BubblePanel assignmentBubble = new BubblePanel(BubblePanel.BUBBLE_IMAGE_NE, assignmentPanel); 187 BubblePanel assignmentBubble = new BubblePanel(BubblePanel.BUBBLE_IMAGE_NE, assignmentPanel);
187 dinoPanel.addBubble(500, 200, assignmentBubble); 188 dinoPanel.addBubble(500, 200, assignmentBubble);
188 } 189 }