From d3952babdcf6567b1fbf460fc7eb1ff058648efc Mon Sep 17 00:00:00 2001 From: Dominik Gruntz Date: Fri, 27 Jul 2018 12:39:35 +0200 Subject: [PATCH] Adds a thread In this example you demonstrate how a property can be bound to an element in a ObservableMap. However, the data in the map does not change, and this is what this change does, i.e. a thread is started which increases each sec the values by 10%. This is a change in a part of the code which is not contained in the book. --- .../main/java/de/javafxbuch/ValueAtBinding.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Kapitel 3/3.4.5/binding-valueAt/src/main/java/de/javafxbuch/ValueAtBinding.java b/Kapitel 3/3.4.5/binding-valueAt/src/main/java/de/javafxbuch/ValueAtBinding.java index 5c4665c..754c8cb 100644 --- a/Kapitel 3/3.4.5/binding-valueAt/src/main/java/de/javafxbuch/ValueAtBinding.java +++ b/Kapitel 3/3.4.5/binding-valueAt/src/main/java/de/javafxbuch/ValueAtBinding.java @@ -39,6 +39,21 @@ public void start(Stage primaryStage) { primaryStage.setScene(scene); System.out.println("You have been Rick rolled!"); primaryStage.show(); + + Thread t = new Thread(()->{ + while(true) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // ignored intentionally + } + for(String key: observableMap.keySet()) { + observableMap.put(key, observableMap.get(key)*1.1); + } + } + + }); + t.start(); } /**