JavaFX communication between controllers 📣

  Рет қаралды 98,285

Bro Code

Bro Code

Күн бұрын

Пікірлер
@BroCodez
@BroCodez 4 жыл бұрын
//-----------------------------------------Main.java-------------------------------------------- package application; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.stage.Stage; import javafx.scene.Parent; import javafx.scene.Scene; public class Main extends Application { @Override public void start(Stage stage) { try { Parent root = FXMLLoader.load(getClass().getResource("Scene1.fxml")); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); } catch(Exception e) { e.printStackTrace(); } } public static void main(String[] args) { launch(args); } } //-----------------------------------------Scene1.fxml----------------------------------------- //-----------------------------------------Scene2.fxml----------------------------------------- //----------------------------------Scene1Controller.java----------------------------------- package application; import java.io.IOException; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.TextField; import javafx.stage.Stage; public class Scene1Controller { @FXML TextField nameTextField; private Stage stage; private Scene scene; private Parent root; public void login(ActionEvent event) throws IOException { String username = nameTextField.getText(); FXMLLoader loader = new FXMLLoader(getClass().getResource("Scene2.fxml")); root = loader.load(); Scene2Controller scene2Controller = loader.getController(); scene2Controller.displayName(username); //root = FXMLLoader.load(getClass().getResource("Scene2.fxml")); stage = (Stage)((Node)event.getSource()).getScene().getWindow(); scene = new Scene(root); stage.setScene(scene); stage.show(); } } //----------------------------------Scene2Controller.java----------------------------------- package application; import javafx.fxml.FXML; import javafx.scene.control.Label; public class Scene2Controller { @FXML Label nameLabel; public void displayName(String username) { nameLabel.setText("Hello: " + username); } } //--------------------------------------------------------------------------------------------------
@tuV13ja
@tuV13ja 4 жыл бұрын
Can you make a video about good practices/design patterns for data validation from UI and comunication with business logic ???? I've never seen a video about it, so you can be the chosen one for this job :')
@اماديرأمان
@اماديرأمان 3 жыл бұрын
We need more javafx videos ,you do the job very simple and easy to understand thanks professor
@devguyahnaf
@devguyahnaf 4 жыл бұрын
I was just searching for some Java tutorials and this channel has the best one. I am a fellow bro now :D
@اماديرأمان
@اماديرأمان 3 жыл бұрын
It's true ,it brings me a lot Just fellow lessons
@amorfati4559
@amorfati4559 3 жыл бұрын
This is so much simpler than how my professor demonstrated. Thanks bro
@JefffMocha
@JefffMocha 6 ай бұрын
If you get an error when clicking the Login button, make sure that your Scene2.fxml document has Scene2Controller as its controller.
@saleemf340
@saleemf340 2 ай бұрын
this comment saved me
@markstockan6333
@markstockan6333 12 күн бұрын
I had this issue too and I had neglected to do this so maybe it was omitted in the video or I missed it but got it working finally after a lot of head scratching.
@mytestaccount23
@mytestaccount23 Жыл бұрын
Really easy to follow and informative videos about JavaFX. Thanks for making these videos
@lequangnghi194
@lequangnghi194 2 жыл бұрын
I don't know why I run into a NullPointerException at this line of code: scene2Controller.displayName(userName); Edit: Never mind! I just forgot to add Controller class
@abhisheksahu6421
@abhisheksahu6421 2 жыл бұрын
i am getting error can you share what fixed yours
@lequangnghi194
@lequangnghi194 2 жыл бұрын
@@abhisheksahu6421 You need to link your Controller in SceneBuilder
@abhisheksahu6421
@abhisheksahu6421 2 жыл бұрын
@@lequangnghi194 thanks
@user-yz5hj3zg2x
@user-yz5hj3zg2x Жыл бұрын
thank you!!
@singhsachin12345
@singhsachin12345 Жыл бұрын
i am unable to fix it can you tell me the clear solution
@okdai2020
@okdai2020 13 күн бұрын
One of the clearest lesson on youtube!!!
@konstandinosdimitriou2301
@konstandinosdimitriou2301 Жыл бұрын
Once again your video saved me from missing a deadline in uni ! bro code your my favorite programing teacher
@TheGreat8220
@TheGreat8220 2 жыл бұрын
This is the best Java channel I've found so far!
@Rumen35
@Rumen35 3 жыл бұрын
I wish i found this video a month ago. Keep up the good work bro
@edwardesqueda4759
@edwardesqueda4759 4 жыл бұрын
Love all your videos! There aren’t enough JAVAFX videos up!
@stephenkyanda8311
@stephenkyanda8311 2 жыл бұрын
easy and simple to follow, even one can unders tand step without voice noted embeded
@Stebandisousa
@Stebandisousa 2 жыл бұрын
Thanks dude, you're a god, best tutorials ever, like and recommend!
@kvsw6296
@kvsw6296 4 жыл бұрын
Amazing tutorial! Thank you very much for this video
@gerdsfargen6687
@gerdsfargen6687 Жыл бұрын
You saved my coding skin! Thank you so much, man!
@HeluAcademyXBrainBoosters
@HeluAcademyXBrainBoosters 4 жыл бұрын
I am a fellow bro ....Yes boss
@minduin90
@minduin90 2 жыл бұрын
Thanks bro! This tips is very helpful to me
@katt2478
@katt2478 2 жыл бұрын
hey please! how can I just get the data in the same way but to more than just one controller??? like i wanna get that same data from scene 1 to scene 2 , scene 3, and scene 4 ??? please help !!
@amir_edlbi
@amir_edlbi 3 жыл бұрын
You saved me. Thanks a lot.
@brandonjablasone7544
@brandonjablasone7544 11 ай бұрын
Bro you are really the goat
@sanskarsongara2592
@sanskarsongara2592 4 жыл бұрын
From today, I'm a fellow bro :-)
@mohamadghobadi5043
@mohamadghobadi5043 3 жыл бұрын
Excellent Useful Thank you very much
@umarqazi9113
@umarqazi9113 2 жыл бұрын
Best one out there!
@mohamadghobadi5043
@mohamadghobadi5043 3 жыл бұрын
Please be the next media player tutorial (audio and video) I will only learn from your channel
@wolanus
@wolanus 3 жыл бұрын
Great video!
@tesseractentertainmentnetw2570
@tesseractentertainmentnetw2570 3 жыл бұрын
Hello! Hoping for some help, I'm having issues getting an ClassCastException with the Scene2Controller scene2controller = loader.getcontroller(); piece, the only thing i'm doing differently is using a package, could that be effecting how this should work?
@CRASH4R
@CRASH4R 11 ай бұрын
Bro, i watch this video now and i have the same problem. If actuality: "Scene2.fxml" have , u should change
@socaljusticewarrior558
@socaljusticewarrior558 2 жыл бұрын
I hate JavaFX. I would much rather work with Swing. It's baffling that I have to create a class, create an XML file(excuse me, an "FXML" file) for the class to load, then specify in the FXML file that I want to have these methods and objects. It's super redundant, but it's easier to update and modify than the Swing GUIs, so I guess employers like it for that reason.
@اماديرأمان
@اماديرأمان 3 жыл бұрын
What about if I want to update a method in differnt controller from another controller
@KaraSuraDraw1
@KaraSuraDraw1 3 жыл бұрын
Heey, im not sure if you can respond as quickly as possible, but how do you pass boolean values of Radio Buttons to another controller? I want to do something if a certain Radio Button is clicked.
@igorsantanas
@igorsantanas 2 жыл бұрын
Thanks Bro, that helps a lot!
@MrPlaybook
@MrPlaybook 5 ай бұрын
Bro adamdır!
@TheGalactusDiet
@TheGalactusDiet 2 ай бұрын
Love it.
@ashkanshakiba9579
@ashkanshakiba9579 3 жыл бұрын
Useful 👌👍
@arshahin9803
@arshahin9803 2 жыл бұрын
awesome!
@tuV13ja
@tuV13ja 4 жыл бұрын
You explain so well dude! And you even go directly to the point, thanks for making my time worth :D good job sub++ from Argentina :p
@15bigchina
@15bigchina 3 жыл бұрын
Thanks for sharing this video , it's really helpful. Only one question that my scene1 login button can't link to login action. no drop-down available and if I type "login" manually show javafx.fxml.LoadException: No controller specified
@valitx8129
@valitx8129 2 жыл бұрын
You need to choose the Controller class from the left bottom section, below the Hierarchy, called Controller. Then you will see the drop-down menu and the variables to link.
@vincentparkes2513
@vincentparkes2513 Жыл бұрын
Nice🙂
@Mars-sm
@Mars-sm Жыл бұрын
Thank you, bro!
@kimevar
@kimevar 4 жыл бұрын
Nice video
@MrsAhmed-lr1sp
@MrsAhmed-lr1sp Жыл бұрын
nice show()
@MrDritzii
@MrDritzii 4 жыл бұрын
love you bro
@silvergodanalyser7762
@silvergodanalyser7762 4 жыл бұрын
Hey Mate thanks for the vid! Can you link your Eclipse theme? I have already a black one, but yours look better and the overlay (HUD) with the projects are also black and not (like now) only the main window with the code.
@JavaMoth
@JavaMoth Жыл бұрын
Omg finally was able to shut down that executor from the controller file on app exit
@Not_Yukii
@Not_Yukii 2 жыл бұрын
Thanks you so much !
@chemso_1
@chemso_1 8 ай бұрын
da best
@tharinmahale9878
@tharinmahale9878 3 жыл бұрын
Thanks this helped me alot
@shahzaibmalik9264
@shahzaibmalik9264 3 жыл бұрын
thanks bro
@tttttroll
@tttttroll 2 жыл бұрын
But how can you do this with a label and not passing information through a text box?
@csubh
@csubh 2 жыл бұрын
for some reason it shows Node cannot be resolved to a type in the main controller class
@longkesh1971
@longkesh1971 2 ай бұрын
Thanks bro.
@deividimizael
@deividimizael Жыл бұрын
Thanks, I Love you
@الاءالاحمدي-غ1ز
@الاءالاحمدي-غ1ز Жыл бұрын
How can I use Javafx to drawing line by using dda algorithm.¿
@berriahzaki7827
@berriahzaki7827 2 жыл бұрын
plz help me i have this problem class com.example.demo1.Nouvauxlocataire cannot be cast to class javafx.scene.Parent
@Arxa93
@Arxa93 3 жыл бұрын
Thank you
Жыл бұрын
Thanks.
@mcfrizzlefries5537
@mcfrizzlefries5537 4 жыл бұрын
Hell yeah, thanks bro code
@hamzachiguer642
@hamzachiguer642 Жыл бұрын
thank you bro
@yassiressaid3140
@yassiressaid3140 4 жыл бұрын
can you do a java dao toturial with practical example
@BroCodez
@BroCodez 4 жыл бұрын
not a bad idea!
@NagaVenkateshgavini
@NagaVenkateshgavini 2 жыл бұрын
good :)
@AI-lf7fl
@AI-lf7fl 4 жыл бұрын
I'm a faaaan of yours
@Dswilsonangel
@Dswilsonangel 2 жыл бұрын
Thanks!!!!!!!!!😁
@ICantCodeYet
@ICantCodeYet 7 ай бұрын
I love Bro Code
@Verzach3
@Verzach3 4 жыл бұрын
KZbin doesn't notify this video to me :c
@Stella_8008
@Stella_8008 3 жыл бұрын
Does not work for me i get a big error Nvm Got it to work :D (btw your tutorials are so fun and good to watch thank you!)
@ut5671
@ut5671 3 жыл бұрын
i got an exception ...whenever i clicked login...i used the same code..can u help me out plz
@augischadiegils.5109
@augischadiegils.5109 4 жыл бұрын
Tnx bro
@teamwang4968
@teamwang4968 Жыл бұрын
I have a question lets say i wanna let the user put his first name and his last name so I change the scene2Controller to: public void displayerName (String username, String theLastName){ nameLabel.setText("hello:"+username +" "+ theLastName); } and the scene1Contoller to a: theHelloSceneController.displayerName(username , theLastName); with of course adding String theLastName = userlastName.getText(); put it doesn't log in and move to the Scene2 what should i do please help
@berriahzaki7827
@berriahzaki7827 2 жыл бұрын
class com.example.demo1.Nouvauxlocataire cannot be cast to class javafx.scene.Parent
@aliwissam9672
@aliwissam9672 4 жыл бұрын
Do you use discord?
@BroCodez
@BroCodez 4 жыл бұрын
I do for personal use, but I don't have a server set up for this channel
@ahmedmouad344
@ahmedmouad344 Жыл бұрын
i dont really know why everyone uses fxml instead of Java it self to build things this is not the only course that does this and i wanna learn java not xml ..:(
@cinnamonshake45
@cinnamonshake45 Ай бұрын
then use Scene builder... using java to build is a really tedious process, and becomes unmanageable if youre seriously developing an application
@srinicnu5283
@srinicnu5283 3 жыл бұрын
i want the src code plz its urgent
@hananetahrat6820
@hananetahrat6820 9 ай бұрын
It not work
@inhtrongthang3367
@inhtrongthang3367 3 жыл бұрын
Please kotlin
@amadoutraore1967
@amadoutraore1967 7 ай бұрын
Thank you bro
JavaFX logout/exit button 🚪
9:22
Bro Code
Рет қаралды 40 М.
Using SceneBuilder and Controller class to change scenes in Javafx
14:45
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
JavaFX Multiple Controllers
15:26
MVP Java
Рет қаралды 51 М.
JavaFX switch scenes 💞
8:35
Bro Code
Рет қаралды 178 М.
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 310 М.
JavaFX stages 🎭
13:49
Bro Code
Рет қаралды 133 М.
Use Arc Instead of Vec
15:21
Logan Smith
Рет қаралды 157 М.
The concept of sending data between scenes in JavaFX
5:11
Random code
Рет қаралды 8 М.
JavaFX Event Handling using Scene Builder 🎪
8:31
Bro Code
Рет қаралды 81 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 845 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН