If anyone is confused why there is no drop down for application.Controller at 3:44 , it helped to drag the Main.fxml file into the application folder like he did in the previous video. That makes everything work again and as always, thanks bro ;)
yes it happened to me as well, i just put the Main.fxml file inside the src Folder, and changed the code to: "getResource("Main.fxml"));" and i got the drop down lists working
If anyone gets a ton of errors at 7:10 (or just when you write "@FXML" ) I found a solution. It might mean that you need to export some sort of package that program can't locate or whatever. The general solution to this is: opens to javafx.fxml; (in your case is probably "application") you just have to manually write that code into your fxml file so it looks like this: module SceneBuilderEventHandling { requires javafx.graphics; requires javafx.controls; requires javafx.fxml; requires javafx.base; opens application to javafx.fxml; exports application; }
The Controllers drop-down is missing on my IntelliJ. So, what I did was, I selected the Text tab at the bottom of the FXML file (there are Text and Scene Builder tabs), went to the opening AnchorPane tag, and modified the fx:controller attribute to the controller I set up (in my case, I made it: fx:controller="com.example.demo.E06EventHandlingUsingSceneBuilderController"). And it worked. And the methods showed up in the drop-downs in the Code drop-down on the right panel of the buttons in the Scene Builder tab.
I'm confused on how the x and y are connected to the circle? like ok we hook the circle in scene builder with the myCircle instance, however then we add two doubles which we never initialize and then we tell the methods to use this value for setting the position of the circle, how does the program know what we mean to do?
@@aohoang3215 to me that is a hidden side effect which is undesirable in a tutorial. Someone might try and use this code in a slightly different setup and not understand why it is not working.
For anyone watching in the future it's because numerical primitive types in Java that are not initialized get assigned 0 by default. Then since x and y are both 0 we start at the point 0,0 which happens to be the center of the screen
Actually, Bro I have started learning java rather than stuffing my mind with alot of languages. I don't know yet its end point. I want bro you to help me to learn java well. I will be very thankful to you in my entire life.
I have a question. Aren't x and y initialized to 0? That is, when we press, say, up, the first time, shouldn't the y-value of the center of the circle actually be -10, thus moving it to (0, -10)?
You know, I thought the same thing about someone using NetBeans (if memory serves) for Java Swing). After mulling it over, I came to the conclusion that, while it feels pretty good to type a bunch of code and watch it run, things like NetBeans and SceneBuilder is more efficient. And that means you can get more stuff done. It's like this: Sure I can ride a bicycle 2 miles to the grocery store, but a car is faster and can haul more groceries. Is using a car cheating? Maybe. Maybe not. As long as the job gets done and works as intended, I'm happy.
Not sure if I missed it or I don't understand but how come you don't need to set the initial values for x and y equal to the current x and y of the circle? I was expecting the circle to pop to the left upper corner because the x and y are initially 0
on 2nd thought, i think i got it.. If you set Y to -100 or 100 then you notice initial jumps in the circle. This must mean that its X and Y values don't depend on its parent container (IE, y = 200 doesnt mean 200 pixels below the anchor panel, it means 200 pixels below where the circle is initially placed. And since sceneBuilder takes care of the initial values .setCenterY(); only takes effect after we hit buttons )
Got this error: javafx.fxml.LoadException: Error resolving onAction='#up', either the event handler is not in the Namespace or there is an error in the script.
Hi bro, hope you are fine. Bro, I wish if you make a instagram ID. Just will be need your less time. There are some questions and small helps that we need. You already doing great. And I really learning from you. Can you suggest any book for java.
Like most GUIs, JavaFX thinks that the origin - the point (0,0) - is the top left and everything is measured from there. As there is little use for points above the top of the window or to the left of the left side of the window, the x-axis uses units of pixels going to the right from the origin and the y-axis uses units of pixels going down from the origin.
It could be argued that both are outdated but javafx is less outdated than swing. You are going to get a lot more with less work in javafx, but it more complex in some ways so when things don't go as planned it may be harder to figure out why.
merci pour la vidéo mais penser a faire la traduction en Français pas au niveau sous titre puisque j'ai eu un peu du mal a suivre la vidéo mais c'était cas mm intéressant pour moi
I don't know if any else, whose using Linux, has this problem or not, but SceneBuilder is laggy as hell if used through eclipse. However, if I open it outside of eclipse, it runs smooth as butter. If anyone knows why this is, or how to fix it, then please let me know.
Hi, my code is the same that yours and it's not. working like The Dev says down there but is fix don't work with me. Can you please share for each video the code that works ? Tks Bro 🙂 My error : Caused by: java.lang.NullPointerException: Cannot invoke "javafx.scene.shape.Circle.setCenterY(double)" because "this.myCircle" is null
hey bro, could you make a video on making a mvc project? with interface, abstract class and all of that. Really struggling with it and there's no good explanation on it on youtube
I have paid for the courses, But your tutorials beat them all in Quality and delivery. Thanks Bro.
If anyone is confused why there is no drop down for application.Controller at 3:44 , it helped to drag the Main.fxml file into the application folder like he did in the previous video. That makes everything work again
and as always, thanks bro ;)
tnx very helpful. Did not notice your comment first, almost wasted half day googling
my fxml file is in my class folder tho. there's no drop down.
@@cornmasterliao7080 same
yes it happened to me as well, i just put the Main.fxml file inside the src Folder, and changed the code to: "getResource("Main.fxml"));" and i got the drop down lists working
Thanks 🙏
Один из лучших видеокурсов по JavaFX
i have done it. Thanks. I from Russia and I like your videos about JAVA
If anyone gets a ton of errors at 7:10 (or just when you write "@FXML" ) I found a solution. It might mean that you need to export some sort of package that program can't locate or whatever. The general solution to this is:
opens to javafx.fxml; (in your case is probably "application")
you just have to manually write that code into your fxml file so it looks like this:
module SceneBuilderEventHandling {
requires javafx.graphics;
requires javafx.controls;
requires javafx.fxml;
requires javafx.base;
opens application to javafx.fxml;
exports application;
}
thanks bro!
The Controllers drop-down is missing on my IntelliJ. So, what I did was, I selected the Text tab at the bottom of the FXML file (there are Text and Scene Builder tabs), went to the opening AnchorPane tag, and modified the fx:controller attribute to the controller I set up (in my case, I made it: fx:controller="com.example.demo.E06EventHandlingUsingSceneBuilderController"). And it worked. And the methods showed up in the drop-downs in the Code drop-down on the right panel of the buttons in the Scene Builder tab.
Only You helps me
(Better Than my Teacher)
Excellent tutorials. Bro is a good teacher💪
I just clicked the ad to support you... 😍🙏
I like your videos. You are the best BRO
Thank you so much, your explanation is so clear
I learn php first then go to java, i felt java way more structured than php.
Thank you. You made this easy to understand.
package application;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Parent;
import javafx.scene.Scene;
//-----------------------Main.java-----------------------
public class Main extends Application {
@Override
public void start(Stage stage) {
try {
Parent root = FXMLLoader.load(getClass().getResource("Main.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
//-----------------------Main.fxml-----------------------
//-----------------------Controller.java-----------------------
package application;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.shape.Circle;
public class Controller {
@FXML
private Circle myCircle;
private double x;
private double y;
public void up(ActionEvent e) {
//System.out.println("UP");
myCircle.setCenterY(y-=10);
}
public void down(ActionEvent e) {
//System.out.println("DOWN");
myCircle.setCenterY(y+=10);
}
public void left(ActionEvent e) {
//System.out.println("LEFT");
myCircle.setCenterX(x-=10);
}
public void right(ActionEvent e) {
//System.out.println("RIGHT");
myCircle.setCenterX(x+=10);
}
}
Thanks a lot for your efforts, It helps a lot
I'm confused on how the x and y are connected to the circle? like ok we hook the circle in scene builder with the myCircle instance, however then we add two doubles which we never initialize and then we tell the methods to use this value for setting the position of the circle, how does the program know what we mean to do?
in the middle of the screen is the point (0,0)
@@aohoang3215 to me that is a hidden side effect which is undesirable in a tutorial. Someone might try and use this code in a slightly different setup and not understand why it is not working.
I had been wondering the same thing. Watched through the video several times trying to see what I was missing.
@@jamesschmames6416 @kole1678 It's been 2 years now, do you remember the reason??? I'm stuck at the same place!
For anyone watching in the future it's because numerical primitive types in Java that are not initialized get assigned 0 by default. Then since x and y are both 0 we start at the point 0,0 which happens to be the center of the screen
I learn a lot .tnx
Actually, Bro I have started learning java rather than stuffing my mind with alot of languages. I don't know yet its end point. I want bro you to help me to learn java well. I will be very thankful to you in my entire life.
Great!
I have a question. Aren't x and y initialized to 0? That is, when we press, say, up, the first time, shouldn't the y-value of the center of the circle actually be -10, thus moving it to (0, -10)?
I wonder that too
Nice Video bro ...
Thank you very much! 👍
Super Video
Super explanation 😃
Thanks bro.
Useful 👌👍
Thanks bro helped a lot
Im from Java tutorial just to see if you're still uploading, keep it up!
would you help to determine , maven pom file for this project , (java)thank you
Great video, thanks!
great videos!
Thumb up, great work!!! ... as usual 😉
Dude, i'm in love with these emojis hahaha ♥♥
da best
Thank you so much
After coming from your Java swing tutorials, this SceneBuilder stuff feels like cheating? Am I cheating?
No
You know, I thought the same thing about someone using NetBeans (if memory serves) for Java Swing). After mulling it over, I came to the conclusion that, while it feels pretty good to type a bunch of code and watch it run, things like NetBeans and SceneBuilder is more efficient. And that means you can get more stuff done. It's like this: Sure I can ride a bicycle 2 miles to the grocery store, but a car is faster and can haul more groceries. Is using a car cheating? Maybe. Maybe not. As long as the job gets done and works as intended, I'm happy.
Not sure if I missed it or I don't understand but how come you don't need to set the initial values for x and y equal to the current x and y of the circle? I was expecting the circle to pop to the left upper corner because the x and y are initially 0
If youve figured this out i'd like to know too :(
on 2nd thought, i think i got it..
If you set Y to -100 or 100 then you notice initial jumps in the circle.
This must mean that its X and Y values don't depend on its parent container (IE, y = 200 doesnt mean 200 pixels below the anchor panel, it means 200 pixels below where the circle is initially placed. And since sceneBuilder takes care of the initial values .setCenterY(); only takes effect after we hit buttons )
Great video!
Thank you.
thank you bro
So does the scene builder replace the event handler method with the one we provide?
What is the difference between using swing and javafx
Thanks so much for these useful videos! I hope you won't drop this series, your videos helped me a lot in Java as a beginner.
+ 1 like and subscribe
thanks!
Good
Sir,please upload game devlopment course
thanks bro
thank you
Got this error: javafx.fxml.LoadException: Error resolving onAction='#up', either the event handler is not in the Namespace or there is an error in the script.
Bro,you are legend :D
Awesome!!!! Thanks!!!!!!! :)
So how does this work if you need to access methods that use 'stage,' since `primaryStage` is in your main class, not your controller class?
niceeeeeeeee
thanks bro!
Error: JavaFX runtime components are missing, and are required to run this application how to solve please help IntelliJ
Hi bro, hope you are fine. Bro, I wish if you make a instagram ID. Just will be need your less time. There are some questions and small helps that we need. You already doing great. And I really learning from you. Can you suggest any book for java.
Hey bro, thanks for the great lesson, but mine has a little error it goes to Java Lang error
From Where you learned programing ?
Hey, why to up the circle I use "y -= 10"? In Cartesian plane the y-axis "up" are the positive values, not negatives. What logical JavaFX uses?
Like most GUIs, JavaFX thinks that the origin - the point (0,0) - is the top left and everything is measured from there. As there is little use for points above the top of the window or to the left of the left side of the window, the x-axis uses units of pixels going to the right from the origin and the y-axis uses units of pixels going down from the origin.
how can do it without using sceneBuilder?
what should i learn swing or javafx?
It could be argued that both are outdated but javafx is less outdated than swing. You are going to get a lot more with less work in javafx, but it more complex in some ways so when things don't go as planned it may be harder to figure out why.
merci pour la vidéo mais penser a faire la traduction en Français pas au niveau sous titre puisque j'ai eu un peu du mal a suivre la vidéo mais c'était cas mm intéressant pour moi
subscribed!
I don't know if any else, whose using Linux, has this problem or not, but SceneBuilder is laggy as hell if used through eclipse. However, if I open it outside of eclipse, it runs smooth as butter. If anyone knows why this is, or how to fix it, then please let me know.
no i am using mx linux it works smooth, but facing issue that scene builder is not showing controller class in dropdown
Can I print a variable as a label in SceneBuilder?
How about using Social Media?
Hi,
my code is the same that yours and it's not. working like The Dev says down there but is fix don't work with me.
Can you please share for each video the code that works ?
Tks Bro 🙂
My error :
Caused by: java.lang.NullPointerException: Cannot invoke "javafx.scene.shape.Circle.setCenterY(double)" because "this.myCircle" is null
I found it : my id name was not the same that the variable name grrr !!!
gg
my circle is null '-'
Привет, тебе!
hey bro, could you make a video on making a mvc project? with interface, abstract class and all of that. Really struggling with it and there's no good explanation on it on youtube
Is JavaFX better easier than Java?
_JavaFx is a part of java_
@@rydercarter7035 this made me laugh
bump
Great Video!
Good