Integrating Spring Boot with JavaFX

MVP Java · 46K views · 2016 · 7:44

Open on YouTube

Software architecture & designTesting, debugging & developer toolstutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it when they need a working example of using Spring Boot dependency injection inside JavaFX controllers.

Recommended by 2 people across 2 different months, 2016 to 2020.

What it is

A short tutorial by MVP Java showing how to wire Spring Boot into a JavaFX 8 application. It uses Spring as the controller factory so JavaFX controllers can @Autowire services and beans, and also shows Spring Test for integration tests.

What people said

Recommends Wim Deblauwe · 2016-09 · Stack Overflow · on “How to set 'headless' property in a Spring Boot test?”

I am testing using Spring Boot with JavaFX (Based on some excellent YouTube videos [this video] that explain this). To make it work with TestFX [LINK] , I need to create the context like this: @Override public void init() throws Exception { SpringApplicationBuilder builder = new SpringApplicationBuilder(MyJavaFXApplication.class); builder.headless(false); // Needed for TestFX context = builder.run(getParameters().getRaw().stream().toArray(String[]::new)); FXMLLoader loader = new FXMLLoader(getClass().getResource("main.fxml")); loader.setControllerFactory(context::getBean); rootNode = loader.load(); } I now want to test this JavaFX application, for this I use: @RunWith(SpringRunner.class) @SpringB

Recommends TrialNError · 2020-01 · Stack Overflow · on “Using JavaFX to pass data to an already opened window”

If you are using Spring Boot, MPV Java on YouTube has great examples of connecting your controllers together allowing you to pass information cleanly and easily between them. In my application I've been able to implement these examples. Each controller is registered as a bean using @Component which means you can @Autowire the controller into another controller. In your main controller I would recommend setting up some basic getters/setters to allow outside interaction with your fields so other controllers can "talk" to the main controller. A really basic example would be: @Component public class MyMainController { @FXML private TextField exampleTextField; ... ... /* Get the text of a field f

Cites Victor Harlan Lacson · 2017-09 · Stack Overflow · on “FXMLLoader initialization and SpringBoot - @Configuration”

I have a question from a tutorial by MVP Integrating Spring Boot with JavaFX GitHub: [LINK] Youtube: [this video] where there is a public method named initialization() that I don't know how it is invoked after spring boot application starts up. I looked everywhere in the classes and fxml files that it could have a reference to it, and I found none. I want to know how this method is invoked since I also want to do some initialization of JavaFX controls. I tried using @PostConstruct but this is wrong since all beans are created before any JavaFX controls are created thus I get null pointer exception. I will be very grateful if someone will enlighten me on this matter. here is the class at which the