This is incredible. I've only used the Intellij based video tutorial on integrating both spreingboot and JavaFX...this is a bonus! Thanks so much for your teaching 😊
Something that would be a great follow up to this that I'm having a difficult time with now is how to test JavaFX Spring applications. I know TestFX exists, but it doesn't "just" work with @SpringBootTest
You'd let Spring inject the applicationContext into your Controller and push a new StageReadyEvent to it. The event's constructor is not being called with the primaryStage, but with a simple new Stage() as argument instead.
Great video, but if I want to switch stages (load another fxml on button click) how can I do it? (I'm trying to do a login system, to switch between login screen and main screen)
@@blackandyelllow5891 Yes I did. I just created a setter for the ApplicationContext in the main window controller and I called it from the login controller in the login method. You also need to do that if you use a logout etc. It's probably not the cleanest way but it does work. Example below ---- LOGIN METHOD CODE --- @FXML public void login(ActionEvent event) throws IOException, NoSuchAlgorithmException { if (!tfemail.getText().isEmpty() && !pf_pass.getText().isEmpty()) { String email = tfemail.getText(); String pass = getMD5(pf_pass.getText()); userService = ac.getBean(UserService.class); if(userService.authenticate(email, pass)){ Notary not= userService.findByEmail(email); long id=not.getCode(); ((Node)event.getSource()).getScene().getWindow().hide(); FXMLLoader loader=new FXMLLoader(getClass().getResource("/home.fxml")); Pane root = loader.load(); Home home = loader.getController(); home.setAc(ac); home.setCode(id); Stage rgstage=new Stage(); Scene scene=new Scene(root); rgstage.setTitle("iNotary"); rgstage.setScene(scene); rgstage.show(); ... ______________________________________ ----FROM MAIN CONTROLLER_________ private ApplicationContext ac; public void setAc(ApplicationContext ac) { this.ac = ac; }
@@bonammanikanta6682I came to this in 2023. Is there no possible way to do this ...as you could simply add the code into a StageInitializer Class could you not?
I have successfully ran the app, but i can't find a way to properly go to another fxml - i get a java.lang.nullpointerexception. Thing is that it always gives the error when i run a method inside the controller. As i made my research, i found out that spring must manage the controller for the fxml. But i cant find a way to do that. Only the first fxml that will get loaded works well with it's controller. @SpringDeveloper could you help me on that please?
When i had my previous app without spring, i had a class "browser", and by using an instance of this browser class i was getting the stage and i was setting another scene using another fxml.
Can anyone help or spring developer With this example ,actually I configured spring JDBC template in same as we do in web application but It gives null in StageListner. How to do it? If possible please show add one video spring JDBC with this example at least..
The same way as you'd do it usually with Spring: add Spring Data & JDBC dependencies, configure it in your application properties. Done. Every tutorial about it still apply in this scenario.
@@kotivideos7140 and you instantly start to suffer with all this some kinda Apps...like skype and so on...because in one day js devs think that they could implement backend)
This is incredible. I've only used the Intellij based video tutorial on integrating both spreingboot and JavaFX...this is a bonus! Thanks so much for your teaching 😊
I used spring boot with JavaFX and I was so freaking amazed.
Oldie but goldie. Thanks.
Thank you so much this tutorial saved my life. Much thanks
Great stuff here, thanks a lot !!
Thanks a lot. Very useful and such a clear explanation
Worked like a song. Thanks :-)
Something that would be a great follow up to this that I'm having a difficult time with now is how to test JavaFX Spring applications. I know TestFX exists, but it doesn't "just" work with @SpringBootTest
The best and the easiest explanition.Thank you
I used spring dm in a couple of large eclipse rcp apps
Where do you use reactive-web dependency?
Thank you for this content. Question, how would i go about calling and hiding other UI's?
You'd let Spring inject the applicationContext into your Controller and push a new StageReadyEvent to it. The event's constructor is not being called with the primaryStage, but with a simple new Stage() as argument instead.
Thats nice!! BUT what about mapping entities as javafx uses beans properties! Spring will recognize that????
Great video, but if I want to switch stages (load another fxml on button click) how can I do it? (I'm trying to do a login system, to switch between login screen and main screen)
Did you find the answer of the question? Help would be much appreciated
@@blackandyelllow5891 Yes I did. I just created a setter for the ApplicationContext in the main window controller and I called it from the login controller in the login method. You also need to do that if you use a logout etc. It's probably not the cleanest way but it does work. Example below
---- LOGIN METHOD CODE ---
@FXML
public void login(ActionEvent event) throws IOException, NoSuchAlgorithmException {
if (!tfemail.getText().isEmpty() && !pf_pass.getText().isEmpty()) {
String email = tfemail.getText();
String pass = getMD5(pf_pass.getText());
userService = ac.getBean(UserService.class);
if(userService.authenticate(email, pass)){
Notary not= userService.findByEmail(email);
long id=not.getCode();
((Node)event.getSource()).getScene().getWindow().hide();
FXMLLoader loader=new FXMLLoader(getClass().getResource("/home.fxml"));
Pane root = loader.load();
Home home = loader.getController();
home.setAc(ac);
home.setCode(id);
Stage rgstage=new Stage();
Scene scene=new Scene(root);
rgstage.setTitle("iNotary");
rgstage.setScene(scene);
rgstage.show();
...
______________________________________
----FROM MAIN CONTROLLER_________
private ApplicationContext ac;
public void setAc(ApplicationContext ac) {
this.ac = ac;
}
@@nickoskordas9247 Thank you for posting this. Was having the same issue.
@nickoskordas9247 you the man! 😊
@@nickoskordas9247 thelo na se efharistiso!
Just a quick question if you could answer, would it be possible to use javafx and spring boot but without FXML ? all UI would be done in javafx code
Not possible
@@bonammanikanta6682I came to this in 2023. Is there no possible way to do this ...as you could simply add the code into a StageInitializer Class could you not?
Amazing tutorial, ty very much!
Do you have github Repo for this? I tried it but get some errors after coding your tutorial.
github.com/spring-tips/javafx
I have successfully ran the app, but i can't find a way to properly go to another fxml - i get a java.lang.nullpointerexception. Thing is that it always gives the error when i run a method inside the controller. As i made my research, i found out that spring must manage the controller for the fxml. But i cant find a way to do that. Only the first fxml that will get loaded works well with it's controller. @SpringDeveloper could you help me on that please?
When i had my previous app without spring, i had a class "browser", and by using an instance of this browser class i was getting the stage and i was setting another scene using another fxml.
Wooooo !!!!
this is awesome, thanks...
I keep getting this weird error which says the modena.css isn't found
I have repeated all lines of code in video and Spring Boot dont want to show stage frame :\
OK... you are a very good programmer. But try to mix Spring Boot with JavaFX is absolutly INSANE...!!
Nice
Can anyone help or spring developer With this example ,actually I configured spring JDBC template in same as we do in web application but It gives null in StageListner. How to do it? If possible please show add one video spring JDBC with this example at least..
how to connect mysql (spring+javafx+mysql)
The same way as you'd do it usually with Spring: add Spring Data & JDBC dependencies, configure it in your application properties. Done. Every tutorial about it still apply in this scenario.
It's only working in Fist controller.. It not working in second controller throws the null pointer exception
😋
You could left the source code for us.
1st like 👍
Javafx 2019 lol
There is something bad use it?!
@@davidsalleyezonme1283 its dead, you have electronJS for desktop and soon flutter for desktop too
@@kotivideos7140 and you instantly start to suffer with all this some kinda Apps...like skype and so on...because in one day js devs think that they could implement backend)
@@evko9264 flutter is not js it will take over soon
Koti Crypto how mobile framework will take over desktop app? (Migration from desktop to mobile excluded)