File tree Expand file tree Collapse file tree
ProfCalculator/src/de/uulm/sp/swt/profcalculator Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package de .uulm .sp .swt .profcalculator ;
22
33import de .uulm .sp .swt .profcalculator .expressions .Addition ;
4+ import de .uulm .sp .swt .profcalculator .expressions .CounterValue ;
45import de .uulm .sp .swt .profcalculator .expressions .Expression ;
56import de .uulm .sp .swt .profcalculator .expressions .Multiplication ;
67import de .uulm .sp .swt .profcalculator .expressions .NecessaryBrackets ;
2122
2223public class ProfCalculator extends Application implements EventHandler <ActionEvent > {
2324
24- private final static Value DEFAULT_VALUE = new Value (0 );
25-
26- private Expression expression = DEFAULT_VALUE ;
25+ private Expression expression = new CounterValue (this );
2726
2827 private GUIFactory guiFactory = new BlueFontGUIFactory ();
2928
@@ -72,7 +71,7 @@ else if (event.getSource() == multiplicationButton) {
7271 }
7372 }
7473
75- private void updateGUI () {
74+ public void updateGUI () {
7675 resultLabel .setText (expression .computeEquation ());
7776 inputField .setText ("" );
7877 errorLabel .setText ("" );
Original file line number Diff line number Diff line change 1+ package de .uulm .sp .swt .profcalculator .expressions ;
2+
3+ import de .uulm .sp .swt .profcalculator .ProfCalculator ;
4+ import javafx .application .Platform ;
5+
6+ public class CounterValue extends Value implements Runnable {
7+
8+ ProfCalculator calc ;
9+
10+ public CounterValue (ProfCalculator calc ) {
11+ super (0 );
12+ this .calc = calc ;
13+ new Thread (this ).start ();
14+ }
15+
16+ @ Override
17+ public void run () {
18+ while (value < 10 ) {
19+ try {
20+ Thread .sleep (1000 );
21+ } catch (InterruptedException e ) {
22+ }
23+ value ++;
24+ Platform .runLater (new Runnable () {
25+ public void run () {
26+ calc .updateGUI ();
27+ }
28+ });
29+ }
30+ }
31+
32+ }
You can’t perform that action at this time.
0 commit comments