List of usage examples for com.google.common.util.concurrent Service.Listener Service.Listener
Service.Listener
From source file:GRSX.Main.java
private void loadWindow(Stage mainWindow) throws IOException { this.mainWindow = mainWindow; instance = this; GuiUtils.handleCrashesOnThisThread(); URL location = getClass().getResource("main.fxml"); FXMLLoader loader = new FXMLLoader(location); mainUI = loader.load();/*w w w. j av a2 s .c o m*/ controller = loader.getController(); notificationBar = new NotificationBarPane(mainUI); mainWindow.setTitle(APP_NAME); uiStack = new StackPane(); Scene scene = new Scene(uiStack); TextFieldValidator.configureScene(scene); scene.getStylesheets().add(getClass().getResource("wallet.css").toString()); uiStack.getChildren().add(notificationBar); mainWindow.setScene(scene); mainWindow.setResizable(false); //saving this for later for when i can work out .fxml scaling //mainWindow.setMaxWidth(Screen.getPrimary().getBounds().getWidth() / 2); //mainWindow.setMaxHeight(Screen.getPrimary().getBounds().getHeight() / 2); mainWindow.setMaxWidth(800); mainWindow.setMaxHeight(451); //using an online image to update the icon on the fly without needing to push new builds, just because i want to. mainWindow.getIcons().add(new Image("https://duudl3.xyz/img/vortex_wallet_logo.png")); BriefLogFormatter.init(); Threading.USER_THREAD = Platform::runLater; setupWalletKit(null); if (groestlcoin.isChainFileLocked()) { informationalAlert("Vortex Notification", "Vortex is already running and cannot be started twice."); Platform.exit(); return; } mainWindow.show(); groestlcoin.addListener(new Service.Listener() { @Override public void failed(Service.State from, Throwable failure) { GuiUtils.crashAlert(failure); } }, Platform::runLater); groestlcoin.startAsync(); }
From source file:cryptwallet.Main.java
private void realStart(Stage mainWindow) throws IOException { this.mainWindow = mainWindow; instance = this; // Show the crash dialog for any exceptions that we don't handle and that hit the main loop. GuiUtils.handleCrashesOnThisThread(); if (System.getProperty("os.name").toLowerCase().contains("mac")) { // We could match the Mac Aqua style here, except that (a) Modena doesn't look that bad, and (b) // the date picker widget is kinda broken in AquaFx and I can't be bothered fixing it. // AquaFx.style(); }/*from w w w . j a va 2 s. co m*/ // Load the GUI. The MainController class will be automagically created and wired up. URL location = getClass().getResource("main.fxml"); FXMLLoader loader = new FXMLLoader(location); mainUI = loader.load(); controller = loader.getController(); // Configure the window with a StackPane so we can overlay things on top of the main UI, and a // NotificationBarPane so we can slide messages and progress bars in from the bottom. Note that // ordering of the construction and connection matters here, otherwise we get (harmless) CSS error // spew to the logs. notificationBar = new NotificationBarPane(mainUI); mainWindow.setTitle(APP_NAME); uiStack = new StackPane(); Scene scene = new Scene(uiStack); TextFieldValidator.configureScene(scene); // Add CSS that we need. scene.getStylesheets().add(getClass().getResource("crypt.css").toString()); uiStack.getChildren().add(notificationBar); mainWindow.setScene(scene); // Make log output concise. BriefLogFormatter.init(); // Tell bitcoinj to run event handlers on the JavaFX UI thread. This keeps things simple and means // we cannot forget to switch threads when adding event handlers. Unfortunately, the DownloadListener // we give to the app kit is currently an exception and runs on a library thread. It'll get fixed in // a future version. Threading.USER_THREAD = Platform::runLater; // Create the app kit. It won't do any heavyweight initialization until after we start it. setupWalletKit(null); if (bitcoin.isChainFileLocked()) { informationalAlert("Already running", "This application is already running and cannot be started twice."); Platform.exit(); return; } mainWindow.show(); CryptSetPasswordController.estimateKeyDerivationTimeMsec(); bitcoin.addListener(new Service.Listener() { @Override public void failed(Service.State from, Throwable failure) { GuiUtils.crashAlert(failure); } }, Platform::runLater); bitcoin.startAsync(); scene.getAccelerators().put(KeyCombination.valueOf("Shortcut+F"), () -> bitcoin.peerGroup().getDownloadPeer().close()); }