List of usage examples for javafx.application Platform exit
public static void exit()
From source file:com.cdd.bao.editor.EditSchema.java
public void actionFileQuit() { if (!confirmClose()) return; Platform.exit(); }
From source file:net.rptools.tokentool.controller.TokenTool_Controller.java
public void exitApplication() { try {// w w w . j av a 2 s . c o m AppPreferences.savePreferences(this); } catch (Exception e) { log.error("Error saving preferences!", e); } finally { log.info("Exiting application."); Platform.exit(); } }
From source file:org.yccheok.jstock.gui.JStock.java
private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed isFormWindowClosedCalled = true;//w w w . jav a2 s . c o m try { ExecutorService _stockInfoDatabaseMetaPool = this.stockInfoDatabaseMetaPool; this.stockInfoDatabaseMetaPool = null; _stockInfoDatabaseMetaPool.shutdownNow(); // Always be the first statement. As no matter what happen, we must // save all the configuration files. this.save(); if (this.needToSaveUserDefinedDatabase) { // We are having updated user database in memory. // Save it to disk. this.saveUserDefinedDatabaseAsCSV(jStockOptions.getCountry(), stockInfoDatabase); } // Hide the icon immediately. TrayIcon _trayIcon = trayIcon; if (_trayIcon != null) { SystemTray.getSystemTray().remove(_trayIcon); trayIcon = null; } dettachAllAndStopAutoCompleteJComboBox(); this.indicatorPanel.dettachAllAndStopAutoCompleteJComboBox(); log.info("latestNewsTask stop..."); if (this.latestNewsTask != null) { this.latestNewsTask.cancel(true); } _stockInfoDatabaseMetaPool.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); // We suppose to call shutdownAll to clean up all network resources. // However, that will cause Exception in other threads if they are still using httpclient. // Exception in thread "Thread-4" java.lang.IllegalStateException: Connection factory has been shutdown. // // MultiThreadedHttpConnectionManager.shutdownAll(); log.info("Widnow is closed."); } catch (Exception exp) { log.error("Unexpected error while trying to quit application", exp); } Platform.exit(); // All the above operations are done within try block, to ensure // System.exit(0) will always be called. // // Final clean up. System.exit(0); }
From source file:UI.MainStageController.java
/** * method for the quit button/*from www.java 2 s . c o m*/ * opens an alert box * asks whether to save/quit/continue running the program */ private void confirmQuit() { confirmQuitAlert = new Alert(Alert.AlertType.CONFIRMATION); confirmQuitAlert.setTitle("Remember to save your files!"); confirmQuitAlert.setHeaderText("Quit?"); confirmQuitAlert.setContentText("Do you really want to quit?"); ButtonType quitButton = new ButtonType("Quit"); ButtonType saveAndQuitButton = new ButtonType("Save and quit"); ButtonType cancelButton = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); confirmQuitAlert.initModality(Modality.APPLICATION_MODAL); confirmQuitAlert.initOwner(getPrimaryStage()); confirmQuitAlert.getButtonTypes().setAll(quitButton, saveAndQuitButton, cancelButton); Optional<ButtonType> result = confirmQuitAlert.showAndWait(); if (result.get() == quitButton) { Platform.exit(); } else if (result.get() == saveAndQuitButton) { confirmQuitAlert.close(); } else { confirmQuitAlert.close(); } }
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
protected void doClose() { if (logger.isDebugEnabled()) { logger.debug("[DO CLOSE] shutting down"); }/*from ww w . j a v a2 s .c o m*/ if (needsSave.get()) { if (logger.isDebugEnabled()) { logger.debug("[CLOSE] profile needs saving"); } ButtonType myCancel = new ButtonType("Discard Changes", ButtonBar.ButtonData.CANCEL_CLOSE); Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Save profile?", ButtonType.OK, myCancel); alert.setHeaderText("Unsaved profile"); Optional<ButtonType> response = alert.showAndWait(); if (!response.isPresent() || response.get() != ButtonType.OK) { if (logger.isDebugEnabled()) { logger.debug("[CLOSE] skipping save"); } } else { if (logger.isDebugEnabled()) { logger.debug("[CLOSE] saving"); } saveProfile(); needsSave.set(false); // needed in case failure infinite cycle } } Platform.exit(); System.exit(0); // close webstart }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * *//* w ww . ja va 2 s . co m*/ private void projetsFermer() throws IOException { Action reponse = null; Localization.setLocale(locale); if (!dejaSauve) { reponse = Dialogs.create().owner(null).title("Quitter l'application") .masthead("Vous n'avez pas sauvegard votre projet").message("Voulez vous le sauver ?") .showConfirm(); } if (reponse == Dialog.Actions.YES) { try { projetSauve(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } if ((reponse == Dialog.Actions.YES) || (reponse == Dialog.Actions.NO) || (reponse == null)) { sauveHistoFichiers(); deleteDirectory(repertTemp); File ftemp = new File(repertTemp); ftemp.delete(); Platform.exit(); } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @throws IOException Exception d'entre sortie exception *//*from w w w . ja v a 2s . c o m*/ private static void projetsFermer() throws IOException { try { sauvePreferences(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } ButtonType reponse = null; ButtonType buttonTypeOui = new ButtonType(rbLocalisation.getString("main.oui")); ButtonType buttonTypeNon = new ButtonType(rbLocalisation.getString("main.non")); ButtonType buttonTypeAnnule = new ButtonType(rbLocalisation.getString("main.annuler")); if (!isbDejaSauve()) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(rbLocalisation.getString("main.dialog.quitterApplication")); alert.setHeaderText(null); alert.setContentText(rbLocalisation.getString("main.dialog.chargeProjetMessage")); alert.getButtonTypes().clear(); alert.getButtonTypes().setAll(buttonTypeOui, buttonTypeNon, buttonTypeAnnule); Optional<ButtonType> actReponse = alert.showAndWait(); } if (reponse == buttonTypeOui) { try { projetSauve(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } if ((reponse == buttonTypeOui) || (reponse == buttonTypeNon) || (reponse == null)) { sauveHistoFichiers(); deleteDirectory(getStrRepertTemp()); File fileTemp = new File(getStrRepertTemp()); fileTemp.delete(); Platform.exit(); } }