Java Code Examples for javafx.stage.Stage#setOnCloseRequest()

The following examples show how to use javafx.stage.Stage#setOnCloseRequest() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Main.java    From pattypan with MIT License 6 votes vote down vote up
@Override
public void start(Stage stage) {
  Image logo = new Image(getClass().getResourceAsStream("/pattypan/resources/logo.png"));

  Scene scene = new Scene(new StartPane(stage), Settings.getSettingInt("windowWidth"), Settings.getSettingInt("windowHeight"));
  stage.setResizable(true);
  stage.setTitle("pattypan " + Settings.VERSION);
  stage.getIcons().add(logo);
  stage.setScene(scene);
  stage.show();

  stage.setOnCloseRequest((WindowEvent we) -> {
    Settings.setSetting("windowWidth", (int) scene.getWidth() + "");
    Settings.setSetting("windowHeight", (int) scene.getHeight() + "");
    Settings.setSetting("version", Settings.VERSION);
    Settings.saveProperties();
  });
}
 
Example 2
Source File: Console.java    From xframium-java with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void start (Stage primaryStage) throws Exception
{
  this.primaryStage = primaryStage;
  primaryStage.setOnCloseRequest (e -> Platform.exit ());
  primaryStage.setResizable (false);

  pluginsStage = new PluginsStage (prefs);
  

  primaryScreenBounds = javafx.stage.Screen.getPrimary ().getVisualBounds ();
  if (false)
    System.out.println (javafx.stage.Screen.getPrimary ().getDpi ());

  startPartTwo();
}
 
Example 3
Source File: GameClientLobby.java    From Cardshifter with Apache License 2.0 6 votes vote down vote up
private void startNewGame(NewGameMessage message) {
	if (!gamesRunning.isEmpty()) {
		this.chatOutput("You already have a running game. Unable to start a new one.");
		return;
	}

	try {
		FXMLLoader loader = new FXMLLoader(getClass().getResource("ClientDocument.fxml"));
		Parent root = (Parent)loader.load();
		GameClientController controller = loader.<GameClientController>getController();
		this.gamesRunning.add(controller);
		controller.acceptConnectionSettings(message, this::send);
		
		Scene scene = new Scene(root);
		Stage gameStage = new Stage();
		gameStage.setScene(scene);
		gameStage.setOnCloseRequest(windowEvent -> this.closeController(controller));
		gameStage.show();
	}
       catch (Exception e) {
           throw new RuntimeException(e);
       }
}
 
Example 4
Source File: RunDataSetSamples.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
@Override
public void start(final Stage primaryStage) {
    final BorderPane root = new BorderPane();

    final FlowPane buttons = new FlowPane();
    buttons.setAlignment(Pos.CENTER_LEFT);
    root.setCenter(buttons);
    root.setBottom(makeScreenShot);

    buttons.getChildren().add(new MyButton("DataSetToByteArraySample", () -> DataSetToByteArraySample.main(null)));

    final Scene scene = new Scene(root);

    primaryStage.setTitle(this.getClass().getSimpleName());
    primaryStage.setScene(scene);
    primaryStage.setOnCloseRequest(evt -> Platform.exit());
    primaryStage.show();
}
 
Example 5
Source File: NotesApp.java    From FXTutorials with MIT License 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("notes.fxml"));
    Parent root = loader.load();

    stage.setOnCloseRequest(e -> {
        e.consume();
        loader.<NotesController>getController().exit();
    });
    stage.setScene(new Scene(root));
    stage.show();
}
 
Example 6
Source File: Designer.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void start(Stage stage, DesignerRoot owner) throws IOException {
    this.designerRoot = owner;

    stage.setTitle("PMD Rule Designer (v " + Designer.VERSION + ')');
    setIcons(stage);

    Logger.getLogger(Attribute.class.getName()).setLevel(Level.OFF);

    System.out.println(stage.getTitle() + " initializing... ");

    FXMLLoader loader = new FXMLLoader(DesignerUtil.getFxml("designer"));

    MainDesignerController mainController = new MainDesignerController(owner);

    loader.setBuilderFactory(DesignerUtil.customBuilderFactory(owner));

    loader.setControllerFactory(DesignerUtil.controllerFactoryKnowing(
        mainController,
        new MetricPaneController(owner),
        new ScopesPanelController(owner),
        new NodeDetailPaneController(owner),
        new RuleEditorsController(owner),
        new SourceEditorController(owner)
    ));

    stage.setOnCloseRequest(e -> {
        owner.getService(DesignerRoot.PERSISTENCE_MANAGER).persistSettings(mainController);
        Platform.exit();
        // VM sometimes fails to exit for no apparent reason
        // all our threads are killed so it's not our fault
        System.exit(0);
    });

    Parent root = loader.load();
    Scene scene = new Scene(root);

    stage.setScene(scene);

    stage.show();

    if (!owner.isDeveloperMode()) {
        // only close after initialization succeeded.
        // so that fatal errors thrown by stage.show are not hidden
        System.err.close();
    }


    long initTime = System.currentTimeMillis() - initStartTimeMillis;

    System.out.println("done in " + initTime + "ms.");
    if (!owner.isDeveloperMode()) {
        System.out.println("Run with --verbose parameter to enable error output.");
    }
}
 
Example 7
Source File: Loading.java    From DevToolBox with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void startMainApp(Stage ms) {
    try {
        long time = System.currentTimeMillis();
        Stage stage = new Stage();
        stage.setTitle(Undecorator.LOC.getString("AppName") + " " + Undecorator.LOC.getString("Version") + " 版本号:" + Undecorator.LOC.getString("VersionCode"));
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/main.fxml"));
        Region root = (Region) fxmlLoader.load();
        final UndecoratorScene undecoratorScene = new UndecoratorScene(stage, root);
        stage.setOnCloseRequest((WindowEvent we) -> {
            we.consume();
            undecoratorScene.setFadeOutTransition();
        });
        undecoratorScene.getStylesheets().add("/styles/main.css");
        stage.setScene(undecoratorScene);
        stage.toFront();
        stage.getIcons().add(new Image(getClass().getResourceAsStream("/skin/icon.png")));
        stage.setOnShown((event) -> {
            new Timer().schedule(new TimerTask() {
                @Override
                public void run() {
                    Platform.runLater(() -> {
                        ms.close();
                    });
                }
            }, 1000);
        });
        stage.show();
        ApplicationStageManager.putStageAndController(ApplicationStageManager.StateAndController.MAIN, stage, fxmlLoader.getController());
        LOGGER.info("主页面加载耗时:" + (System.currentTimeMillis() - time) + "毫秒");
    } catch (IOException ex) {
        LOGGER.error("启动主程序异常", ex);
    }
}
 
Example 8
Source File: MainLauncher.java    From ClusterDeviceControlPlatform with MIT License 5 votes vote down vote up
private void startApp(Stage primaryStage) {
    primaryStage.setTitle("设备模拟客户端");
    primaryStage.setScene(new Scene(MainView.getInstance()));
    primaryStage.setMaximized(true);
    primaryStage.setOnCloseRequest(event -> NettyLauncher.getInstance().shutdown());
    primaryStage.show();
    MainView.getInstance().updateGroupCount(10);
}
 
Example 9
Source File: RunMathSamples.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
@Override
public void start(final Stage primaryStage) {
    final BorderPane root = new BorderPane();

    final FlowPane buttons = new FlowPane();
    buttons.setAlignment(Pos.CENTER_LEFT);
    root.setCenter(buttons);
    root.setBottom(makeScreenShot);

    buttons.getChildren().add(new MyButton("DataSetAverageSample", new DataSetAverageSample()));
    buttons.getChildren().add(new MyButton("DataSetFilterSample", new DataSetFilterSample()));
    buttons.getChildren()
            .add(new MyButton("DataSetIntegrateDifferentiateSample", new DataSetIntegrateDifferentiateSample()));
    buttons.getChildren()
            .add(new MyButton("DataSetIntegrationWithLimitsSample", new DataSetIntegrationWithLimitsSample()));
    buttons.getChildren().add(new MyButton("DataSetSpectrumSample", new DataSetSpectrumSample()));
    buttons.getChildren().add(new MyButton("EMDSample", new EMDSample()));
    buttons.getChildren().add(new MyButton("FourierSample", new FourierSample()));
    buttons.getChildren().add(new MyButton("FrequencyFilterSample", new FrequencyFilterSample()));
    buttons.getChildren().add(new MyButton("GaussianFitSample", new GaussianFitSample()));
    // buttons.getChildren().add(new MyButton("IIRFilterSample", new IIRFilterSample()));
    buttons.getChildren().add(new MyButton("IIRFrequencyFilterSample", new IIRFrequencyFilterSample()));
    buttons.getChildren().add(new MyButton("ShortTermFourierTransform", new ShortTimeFourierTransformSample()));
    buttons.getChildren().add(new MyButton("TSpectrum", new TSpectrumSample()));
    buttons.getChildren().add(new MyButton("WaveletDenoising", new WaveletDenoising()));
    buttons.getChildren().add(new MyButton("WaveletScalogram", new WaveletScalogram()));

    final Scene scene = new Scene(root);

    primaryStage.setTitle(this.getClass().getSimpleName());
    primaryStage.setScene(scene);
    primaryStage.setOnCloseRequest(evt -> System.exit(0));
    primaryStage.show();
}
 
Example 10
Source File: AbstractDemoApplication.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
@Override
public void start(final Stage primaryStage) {

    final BorderPane root = new BorderPane();
    final Scene scene = new Scene(root, sceneWidth, sceneHeight);

    root.setCenter(getContent());
    primaryStage.setTitle(this.getClass().getSimpleName());
    primaryStage.setScene(scene);
    primaryStage.setOnCloseRequest(evt -> Platform.exit());
    primaryStage.show();
}
 
Example 11
Source File: Main.java    From bandit with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception{
    Arm[] arms = new Arm[]{
            new BernoulliArm(0.015),
            new BernoulliArm(0.02),
            new BernoulliArm(0.01)
    };

    int numArms = arms.length;
    BanditAlgorithm[] algorithms = new BanditAlgorithm[]{
            new EpsilonGreedyAlgorithm(numArms, 0.1),
            new EpsilonFirstAlgorithm(numArms, 1000),
            new SoftmaxAlgorithm(numArms, 0.1),
            new Ucb1Algorithm(numArms)
    };

    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/main_dialog.fxml"));
    MainDialog mainDialog = new MainDialog(arms, algorithms);
    fxmlLoader.setController(mainDialog);

    int minWidth = 800;
    int minHeight = 600;

    primaryStage.setTitle("Bandit Algorithms - Test framework");
    primaryStage.setMinWidth(minWidth);
    primaryStage.setMinHeight(minHeight);
    primaryStage.setOnCloseRequest(mainDialog::handle);
    primaryStage.setScene(new Scene(fxmlLoader.load(), minWidth, minHeight));
    primaryStage.show();
}
 
Example 12
Source File: ADCPreloader.java    From arma-dialog-creator with MIT License 5 votes vote down vote up
@Override
public void start(Stage preloaderStage) throws Exception {
	this.preloaderStage = preloaderStage;
	preloaderStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
		@Override
		public void handle(WindowEvent event) {
			System.exit(0);
		}
	});

	preloaderStage.setTitle(Lang.Application.APPLICATION_TITLE);
	preloaderStage.getIcons().add(ADCIcons.ICON_ADC);
	progressIndicator.setMaxWidth(48d);
	progressIndicator.setMaxHeight(progressIndicator.getMaxWidth());

	VBox vBox = new VBox(5, progressIndicator, lblProgressText);
	vBox.setAlignment(Pos.CENTER);
	VBox.setVgrow(progressIndicator, Priority.ALWAYS);

	Label lblBuild = new Label("Build: " + ArmaDialogCreator.getManifest().getMainAttributes().getValue("Build-Number"));
	Label lblVersion = new Label("Version: " + ArmaDialogCreator.getManifest().getMainAttributes().getValue("Specification-Version"));
	BorderPane borderPane = new BorderPane(vBox, null, null, new HBox(10, lblBuild, lblVersion), null);
	borderPane.setPadding(new Insets(5));

	StackPane.setMargin(borderPane, new Insets(248, 0, 0, 0));
	StackPane stackpane = new StackPane(new ImageView(ADCImagePaths.PRELOAD_SCREEN), borderPane);
	Scene scene = new Scene(stackpane);
	preloaderStage.initStyle(StageStyle.UNDECORATED);
	preloaderStage.setScene(scene);
	preloaderStage.sizeToScene();
	preloaderStage.show();
}
 
Example 13
Source File: AlarmApp.java    From FXTutorials with MIT License 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("ui.fxml"));

    AlarmController controller = new AlarmController(new AlarmModel());
    loader.setController(controller);

    stage.setScene(new Scene(loader.load()));
    stage.setOnCloseRequest(e -> controller.onExit());
    stage.setTitle("Alarm");
    stage.setResizable(false);
    stage.show();
}
 
Example 14
Source File: ExtensionFormLauncher.java    From G-Earth with MIT License 4 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    ExtensionInfo extInfo = extension.getAnnotation(ExtensionInfo.class);

    ExtensionForm creator = extension.newInstance();
    ExtensionForm extensionForm = creator.launchForm(primaryStage);

    extensionForm.extension = new Extension(args) {
        @Override
        protected void initExtension() {
            extensionForm.initExtension();
        }

        @Override
        protected void onClick() {
            extensionForm.onClick();
        }

        @Override
        protected void onStartConnection() {
            extensionForm.onStartConnection();
        }

        @Override
        protected void onEndConnection() {
            extensionForm.onEndConnection();
        }

        @Override
        ExtensionInfo getInfoAnnotations() {
            return extInfo;
        }

        @Override
        protected boolean canLeave() {
            return extensionForm.canLeave();
        }

        @Override
        protected boolean canDelete() {
            return extensionForm.canDelete();
        }
    };
    extensionForm.primaryStage = primaryStage;
    Thread t = new Thread(() -> {
        extensionForm.extension.run();
        //when the extension has ended, close this process
        System.exit(0);
    });
    t.start();

    Platform.setImplicitExit(false);

    primaryStage.setOnCloseRequest(event -> {
        event.consume();
        Platform.runLater(() -> {
            primaryStage.hide();
            extensionForm.onHide();
        });
    });
}
 
Example 15
Source File: MZmineGUI.java    From old-mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public void start(Stage stage) {

    try {
      // Load the main window
      URL mainFXML = new URL(mzMineFXML);
      FXMLLoader loader = new FXMLLoader(mainFXML);

      rootScene = loader.load();
      mainWindowController = loader.getController();
      stage.setScene(rootScene);

    } catch (IOException e) {
      e.printStackTrace();
      logger.error("Error loading MZmine GUI from FXML: " + e);
      Platform.exit();
    }

    stage.setTitle("MZmine " + MZmineCore.getMZmineVersion());
    stage.setMinWidth(300);
    stage.setMinHeight(300);

    // Set application icon
    stage.getIcons().setAll(mzMineIcon);

    stage.setOnCloseRequest(e -> {
      requestQuit();
      e.consume();
    });

    // Activate new GUI-supported project
    MZmineGUIProject project = new MZmineGUIProject();
    MZmineGUI.activateProject(project);

    stage.show();

    // Check for new version of MZmine
    NewVersionCheck NVC = new NewVersionCheck(CheckType.DESKTOP);
    Thread nvcThread = new Thread(NVC);
    nvcThread.setPriority(Thread.MIN_PRIORITY);
    nvcThread.start();
  }
 
Example 16
Source File: ErrorDataSetRendererSample.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
@Override
public void start(final Stage primaryStage) {
    // for extra timing diagnostics
    ProcessingProfiler.setVerboseOutputState(true);
    ProcessingProfiler.setLoggerOutputState(true);
    ProcessingProfiler.setDebugState(false);

    final BorderPane root = new BorderPane();
    final Scene scene = new Scene(root, 800, 600);
    final XYChart chart = new XYChart(new DefaultNumericAxis(), new DefaultNumericAxis());
    chart.legendVisibleProperty().set(true);
    chart.getXAxis().setName("time");
    chart.getXAxis().setUnit("s");
    chart.getXAxis().setAutoUnitScaling(true);

    chart.getYAxis().setName("y-axis");
    chart.getYAxis().setAutoUnitScaling(true);
    chart.legendVisibleProperty().set(true);
    chart.getPlugins().add(new ParameterMeasurements());
    chart.getPlugins().add(new Screenshot());
    chart.getPlugins().add(new EditAxis());
    final Zoomer zoomer = new Zoomer();
    zoomer.setUpdateTickUnit(true);
    // zoomer.setSliderVisible(false);
    // zoomer.setAddButtonsToToolBar(false);
    chart.getPlugins().add(zoomer);
    // chart.getPlugins().add(new DataPointTooltip());
    chart.getPlugins().add(new TableViewer());

    // set them false to make the plot faster
    chart.setAnimated(false);

    final ErrorDataSetRenderer errorRenderer = new ErrorDataSetRenderer();
    chart.getRenderers().setAll(errorRenderer);
    errorRenderer.setErrorType(ErrorStyle.ERRORBARS);
    errorRenderer.setErrorType(ErrorStyle.ERRORCOMBO);
    // errorRenderer.setErrorType(ErrorStyle.ESTYLE_NONE);
    errorRenderer.setDrawMarker(true);
    errorRenderer.setMarkerSize(1.0);
    //        errorRenderer.setPointReduction(false);
    //        errorRenderer.setAllowNaNs(true);

    // example how to set the specifc color of the dataset
    // dataSetNoError.setStyle("strokeColor=cyan; fillColor=darkgreen");

    // init menu bar
    root.setTop(getHeaderBar());

    generateData(dataSet, dataSetNoError);

    long startTime = ProcessingProfiler.getTimeStamp();
    chart.getRenderers().get(0).getDatasets().add(dataSet);
    chart.getRenderers().get(0).getDatasets().add(dataSetNoError);
    ProcessingProfiler.getTimeDiff(startTime, "adding data to chart");

    startTime = ProcessingProfiler.getTimeStamp();
    root.setCenter(chart);
    ProcessingProfiler.getTimeDiff(startTime, "adding chart into StackPane");

    startTime = ProcessingProfiler.getTimeStamp();
    primaryStage.setTitle(this.getClass().getSimpleName());
    primaryStage.setScene(scene);
    primaryStage.setOnCloseRequest(evt -> Platform.exit());
    primaryStage.show();
    ProcessingProfiler.getTimeDiff(startTime, "for showing");
}
 
Example 17
Source File: Gui.java    From ARMStrong with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void start(Stage primaryStage) {
	this.simulator = new ArmSimulator();
	this.executionMode = false;
	this.running = new AtomicBoolean(false);
	this.interfaceBeingUpdated = new AtomicBoolean(false);

	this.stage = primaryStage;

	primaryStage.setTitle("#@RMStrong");
	Image applicationIcon = new Image(Gui.class.getResource("/resources/logo.png").toExternalForm());
	primaryStage.getIcons().add(applicationIcon);
	
	this.dockPane = new DockPane();

	// load an image to caption the dock nodes
	// Image dockImage = new
	// Image(Gui.class.getResource("docknode.png").toExternalForm());

	// creating the nodes
	this.registersViews = new ArrayList<>();
	this.ramViews = new ArrayList<>();
	this.ledViews = new ArrayList<>();
	this.eightSegmentDisplays = new ArrayList<>();
	
	this.codeEditor = new CodeEditor(simulator);
	this.codeEditor.getNode().dock(dockPane, DockPos.LEFT);

	this.registersViews.add(new RegistersView(this.simulator));
	this.registersViews.get(0).getNode().setMaxWidth(220);
	this.registersViews.get(0).getNode().dock(dockPane, DockPos.LEFT);

	this.ramViews.add(new RamView(simulator));
	this.ramViews.get(0).getNode().dock(dockPane, DockPos.RIGHT);


	this.consoleView = new ConsoleView();
	this.consoleView.getNode().dock(dockPane, DockPos.BOTTOM);

	this.consoleView.redirectToConsole();
	
	this.simulator.setConsoleView(this.consoleView);
	
	this.interpreter = new Interpreter(this.simulator);
	this.isInterpreterMode = false;
	
	this.armMenuBar = new ArmMenuBar(this.getHostServices());
	this.armToolBar = new ArmToolBar();

	VBox vbox = new VBox();
	vbox.getChildren().addAll(this.armMenuBar.getNode(), this.armToolBar.getNode(), dockPane);
	VBox.setVgrow(dockPane, Priority.ALWAYS);

	this.scene = new Scene(vbox, 1000, 1000);
	this.stage.setMaximized(true);
	this.stage.setResizable(true);

	primaryStage.setScene(this.scene);
	primaryStage.sizeToScene();

	setButtonEvents();
	setExecutionMode();

	Application.setUserAgentStylesheet(Application.STYLESHEET_MODENA);

	newUpdateThread(this.running);
	
	primaryStage.show();
	primaryStage.setOnCloseRequest((WindowEvent event) -> System.exit(0));
	DockPane.initializeDefaultUserAgentStylesheet();
	
	vbox.getStylesheets().add("/resources/style.css");
	
	System.out.println("Welcome to #@RMStrong Simulator made proudly at the Institute of Technology of Valence in 2018-2019 by fellow students under the guidance of Dr. Philippe Objois!");
	System.out.println("Licensed under the MPL 2.0 License");
	System.out.println("Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi");
}
 
Example 18
Source File: Main.java    From FXTutorials with MIT License 4 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    target.setFill(Color.RED);
    target.setOnMouseClicked(event -> {
        score += 100;
        screenText.setText("Score: " + score);
    });

    screenText.setTranslateX(500);
    screenText.setTranslateY(50);

    gunInfo.setTranslateX(500);
    gunInfo.setTranslateY(100);

    Pane root = new Pane();
    root.setPrefSize(600, 600);
    root.getChildren().addAll(target, screenText, gunInfo);

    Scene scene = new Scene(root);
    scene.setOnMouseClicked(event -> {

        if (event.getButton() == MouseButton.PRIMARY) {
            gun.fire();
        }
        else {
            gun.reload();
        }

        gunInfo.setText("Bullets: " + gun.getClip().getBullets());
    });

    Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(() -> {
        Platform.runLater(() -> {
            target.setTranslateX(Math.random() * 560);
            target.setTranslateY(Math.random() * 560);
        });
    }, 0, 1, TimeUnit.SECONDS);

    primaryStage.setOnCloseRequest(event -> System.exit(0));
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example 19
Source File: ThemeManager.java    From MSPaintIDE with MIT License 4 votes vote down vote up
public void addStage(Stage stage) {
    Scene scene = stage.getScene();
    stage.setOnCloseRequest(event -> removeScene(scene));
    if (!this.scenes.contains(scene)) this.scenes.add(scene);
    selectThemeName(this.activeName);
}
 
Example 20
Source File: NSLMain.java    From ns-usbloader with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception{
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/NSLMain.fxml"));

    Locale userLocale = new Locale(AppPreferences.getInstance().getLanguage());      // NOTE: user locale based on ISO3 Language codes
    ResourceBundle rb = ResourceBundle.getBundle("locale", userLocale);

    loader.setResources(rb);
    Parent root = loader.load();

    primaryStage.getIcons().addAll(
            new Image(getClass().getResourceAsStream("/res/app_icon32x32.png")),
            new Image(getClass().getResourceAsStream("/res/app_icon48x48.png")),
            new Image(getClass().getResourceAsStream("/res/app_icon64x64.png")),
            new Image(getClass().getResourceAsStream("/res/app_icon128x128.png"))
    );

    primaryStage.setTitle("NS-USBloader "+appVersion);
    primaryStage.setMinWidth(650);
    primaryStage.setMinHeight(450);
    Scene mainScene = new Scene(root,
            AppPreferences.getInstance().getSceneWidth(),
            AppPreferences.getInstance().getSceneHeight()
    );

    mainScene.getStylesheets().add(AppPreferences.getInstance().getTheme());

    primaryStage.setScene(mainScene);
    primaryStage.show();

    primaryStage.setOnCloseRequest(e->{
        if (MediatorControl.getInstance().getTransferActive())
            if(! ServiceWindow.getConfirmationWindow(rb.getString("windowTitleConfirmExit"), rb.getString("windowBodyConfirmExit")))
                e.consume();
    });

    NSLMainController controller = loader.getController();
    controller.setHostServices(getHostServices());
    primaryStage.setOnHidden(e-> {
        AppPreferences.getInstance().setSceneHeight(mainScene.getHeight());
        AppPreferences.getInstance().setSceneWidth(mainScene.getWidth());
        controller.exit();
    });
}