From 8b8266f9d699b42ace102bf6942ef6381127be85 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Sun, 10 Nov 2013 18:08:36 +0100 Subject: [PATCH] Wallet template: couple of misc tweaks --- .../src/main/java/wallettemplate/Controller.java | 7 ++----- .../src/main/java/wallettemplate/utils/GuiUtils.java | 9 ++++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/wallettemplate/src/main/java/wallettemplate/Controller.java b/wallettemplate/src/main/java/wallettemplate/Controller.java index 428ec546..a190cb57 100644 --- a/wallettemplate/src/main/java/wallettemplate/Controller.java +++ b/wallettemplate/src/main/java/wallettemplate/Controller.java @@ -8,7 +8,6 @@ import javafx.animation.*; import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.scene.control.Button; -import javafx.scene.control.ContextMenu; import javafx.scene.control.Label; import javafx.scene.control.ProgressBar; import javafx.scene.layout.HBox; @@ -19,9 +18,8 @@ import wallettemplate.controls.ClickableBitcoinAddress; import java.math.BigInteger; import java.util.Date; -import static com.google.common.base.Preconditions.checkState; -import static javafx.application.Platform.isFxApplicationThread; import static wallettemplate.Main.bitcoin; +import static wallettemplate.utils.GuiUtils.checkGuiThread; /** * Gets created auto-magically by FXMLLoader via reflection. The widget fields are set to the GUI controls they're named @@ -32,7 +30,6 @@ public class Controller { public VBox syncBox; public HBox controlsBox; public Label balance; - public ContextMenu addressMenu; public Button sendMoneyOutBtn; public ClickableBitcoinAddress addressControl; @@ -91,7 +88,7 @@ public class Controller { public class BalanceUpdater extends AbstractWalletEventListener { @Override public void onWalletChanged(Wallet wallet) { - checkState(isFxApplicationThread()); + checkGuiThread(); refreshBalanceLabel(); } } diff --git a/wallettemplate/src/main/java/wallettemplate/utils/GuiUtils.java b/wallettemplate/src/main/java/wallettemplate/utils/GuiUtils.java index 87e4deab..1d6728db 100644 --- a/wallettemplate/src/main/java/wallettemplate/utils/GuiUtils.java +++ b/wallettemplate/src/main/java/wallettemplate/utils/GuiUtils.java @@ -18,13 +18,13 @@ import java.util.function.BiConsumer; import static com.google.common.base.Preconditions.checkState; public class GuiUtils { - private static void runAlert(BiConsumer setup) { + public static void runAlert(BiConsumer setup) { try { // JavaFX2 doesn't actually have a standard alert template. Instead the Scene Builder app will create FXML // files for an alert window for you, and then you customise it as you see fit. I guess it makes sense in // an odd sort of way. Stage dialogStage = new Stage(); - dialogStage.initModality(Modality.WINDOW_MODAL); + dialogStage.initModality(Modality.APPLICATION_MODAL); FXMLLoader loader = new FXMLLoader(GuiUtils.class.getResource("alert.fxml")); Pane pane = loader.load(); AlertWindowController controller = loader.getController(); @@ -40,7 +40,10 @@ public class GuiUtils { public static void crashAlert(Throwable t) { t.printStackTrace(); Throwable rootCause = Throwables.getRootCause(t); - Runnable r = () -> runAlert((stage, controller) -> controller.crashAlert(stage, rootCause.toString())); + Runnable r = () -> { + runAlert((stage, controller) -> controller.crashAlert(stage, rootCause.toString())); + Platform.exit(); + }; if (Platform.isFxApplicationThread()) r.run(); else