List of usage examples for javafx.stage Stage setOnHiding
public final void setOnHiding(EventHandler<WindowEvent> value)
From source file:ipat_fx.IPAT_FX.java
@Override public void start(Stage stage) throws Exception { String contextPath = System.getProperty("user.dir") + "/web/"; File logFile = new File(contextPath + "/log/log4j-IPAT.log"); System.setProperty("rootPath", logFile.getAbsolutePath()); Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml")); Scene scene = new Scene(root); stage.setScene(scene);/*from ww w . ja v a 2 s .c o m*/ stage.show(); stage.setOnHiding((WindowEvent event) -> { Platform.runLater(() -> { File src = new File(contextPath + "/Client Data"); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); Date date = new Date(); File dest = new File(contextPath + "/Saves/Ipat_" + dateFormat.format(date)); if (!dest.exists()) { dest.mkdirs(); } try { FileUtils.copyDirectory(src, dest); } catch (IOException ex) { Logger.getLogger(IPAT_FX.class.getName()).log(Level.SEVERE, null, ex); } System.exit(0); }); }); }