diff --git a/wallettemplate/pom.xml b/wallettemplate/pom.xml index 4f4b610fc..1481d9ec6 100644 --- a/wallettemplate/pom.xml +++ b/wallettemplate/pom.xml @@ -46,6 +46,11 @@ 0.1 --> + + org.fxmisc.easybind + easybind + 1.0.0-SNAPSHOT + de.jensd fontawesomefx diff --git a/wallettemplate/src/main/java/wallettemplate/Controller.java b/wallettemplate/src/main/java/wallettemplate/Controller.java index f8ce45a48..ad3718323 100644 --- a/wallettemplate/src/main/java/wallettemplate/Controller.java +++ b/wallettemplate/src/main/java/wallettemplate/Controller.java @@ -11,9 +11,9 @@ import javafx.scene.control.ProgressBar; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.util.Duration; +import org.fxmisc.easybind.EasyBind; import wallettemplate.controls.ClickableBitcoinAddress; import wallettemplate.utils.BitcoinUIModel; -import wallettemplate.utils.WTUtils; import java.util.Date; @@ -42,7 +42,7 @@ public class Controller { public void onBitcoinSetup() { model = new BitcoinUIModel(bitcoin.wallet()); addressControl.addressProperty().bind(model.addressProperty()); - balance.textProperty().bind(WTUtils.bindToString(model.balanceProperty(), Coin::toPlainString)); + balance.textProperty().bind(EasyBind.map(model.balanceProperty(), Coin::toPlainString)); // Don't let the user click send money when the wallet is empty. sendMoneyOutBtn.disableProperty().bind(model.balanceProperty().isEqualTo(Coin.ZERO)); } diff --git a/wallettemplate/src/main/java/wallettemplate/utils/WTUtils.java b/wallettemplate/src/main/java/wallettemplate/utils/WTUtils.java index 90dbb7d63..3f7477041 100644 --- a/wallettemplate/src/main/java/wallettemplate/utils/WTUtils.java +++ b/wallettemplate/src/main/java/wallettemplate/utils/WTUtils.java @@ -1,12 +1,8 @@ package wallettemplate.utils; -import javafx.beans.binding.StringBinding; -import javafx.beans.value.ObservableValue; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.function.Function; - /** * Some generic utilities to make Java a bit less annoying. */ @@ -71,18 +67,4 @@ public class WTUtils { return true; } } - - // Why isn't this a part of the JFX Bindings class? - public static StringBinding bindToString(ObservableValue value, Function function) { - return new StringBinding() { - { - super.bind(value); - } - - @Override - protected String computeValue() { - return function.apply(value.getValue()); - } - }; - } }