show state and allow exit based on state

This commit is contained in:
Andreas Billmann
2015-12-18 12:19:19 +01:00
parent 67f92cd60f
commit c87471f0d1
5 changed files with 147 additions and 25 deletions

View File

@@ -27,9 +27,12 @@
package ninja.javafx.smartcsv.fx;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.EventHandler;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import org.springframework.context.annotation.*;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@@ -46,6 +49,8 @@ public class SmartCSV extends Application {
String name = appContext.getEnvironment().getProperty("application.name");
String version = appContext.getEnvironment().getProperty("application.version");
Platform.setImplicitExit(false);
try {
showUI(primaryStage, name, version);
} catch (Exception e) {
@@ -80,6 +85,12 @@ public class SmartCSV extends Application {
primaryStage.setTitle(String.format("%s %s", name, version));
primaryStage.show();
primaryStage.setMaximized(true);
primaryStage.setOnCloseRequest(event -> {
if (!smartCVSController.canExit()) {
event.consume();
}
});
}
}