Created
February 6, 2017 18:28
-
-
Save 3gcodes/05e5f125ff0f2f8afbfb1267c64b5d1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SpringBootApplication | |
public class DemoApplication extends Application { | |
private ConfigurableApplicationContext springContext; | |
private Parent root; | |
@Override | |
public void init() throws Exception { | |
springContext = SpringApplication.run(DemoApplication.class); | |
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/sample.fxml")); | |
fxmlLoader.setControllerFactory(springContext::getBean); | |
root = fxmlLoader.load(); | |
} | |
@Override | |
public void start(Stage primaryStage) throws Exception{ | |
primaryStage.setTitle("Hello World"); | |
Scene scene = new Scene(root); | |
primaryStage.setScene(scene); | |
primaryStage.show(); | |
} | |
@Override | |
public void stop() throws Exception { | |
springContext.stop(); | |
} | |
public static void main(String[] args) { | |
launch(DemoApplication.class, args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment