package de.felixroske.jfxsupport;

import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;

/**
 * @author Felix Roske 
 */
public abstract class AbstractJavaFxApplicationSupport extends Application {

	private static String[] savedArgs;

	private static Class<? extends AbstractFxmlView> savedInitialView;

	private static ConfigurableApplicationContext applicationContext;

	private static Stage stage;
	private static Scene scene; // = new Scene();

	@Override
	public void init() throws Exception {
		applicationContext = SpringApplication.run(getClass(), savedArgs);
		applicationContext.getAutowireCapableBeanFactory().autowireBean(this);
	}

	@Override
	public void start(Stage stage) throws Exception {
		AbstractJavaFxApplicationSupport.stage = stage;

		showView(savedInitialView);
	}

	public void showView(Class<? extends AbstractFxmlView> newView) {
		AbstractFxmlView view = applicationContext.getBean(newView);
		stage.titleProperty().bind(view.titleProperty());
		if (scene == null) {
			scene = new Scene(view.getView());
		}
		else {  
			scene.setRoot(view.getView());
		}
		
		// stage.setTitle(windowTitle);
		stage.setScene(scene);
//		stage.setResizable(true);
//		stage.centerOnScreen();
		stage.show();
	}

	@Override
	public void stop() throws Exception {

		super.stop();
		applicationContext.close();
	}

	protected static void launchApp(Class<? extends AbstractJavaFxApplicationSupport> appClass,
			Class<? extends AbstractFxmlView> view, String[] args) {
		savedInitialView = view;
		savedArgs = args;
		Application.launch(appClass, args);
	}
}

@@ -466,23 +466,16 @@
 private 
-static 
 Configur
@@ -527,23 +527,16 @@
 private 
-static 
 Stage st
@@ -549,23 +549,16 @@
 private 
-static 
 Scene sc
@@ -566,25 +566,8 @@
 ne; 
-// = new Scene();
 %0A%0A%09@
@@ -687,81 +687,8 @@
 s);%0A
-%09%09applicationContext.getAutowireCapableBeanFactory().autowireBean(this);%0A
 %09%7D%0A%0A
@@ -755,40 +755,12 @@
 %7B%0A%09%09
-AbstractJavaFxApplicationSupport
+this
 .sta
@@ -771,17 +771,16 @@
  stage;%0A
-%0A
 %09%09showVi

Correct static non/static fields