3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-07 14:54:15 +00:00

Wallet template: couple of misc tweaks

This commit is contained in:
Mike Hearn 2013-11-10 18:08:36 +01:00
parent b9363999ae
commit 8b8266f9d6
2 changed files with 8 additions and 8 deletions

View File

@ -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();
}
}

View File

@ -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<Stage, AlertWindowController> setup) {
public static void runAlert(BiConsumer<Stage, AlertWindowController> 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