JavaFX Event Handling using Scene Builder 🎪

Поділитися
Вставка
  • Опубліковано 1 гру 2024

КОМЕНТАРІ • 98

  • @dablo898
    @dablo898 2 роки тому +10

    I have paid for the courses, But your tutorials beat them all in Quality and delivery. Thanks Bro.

  • @stas4112
    @stas4112 2 роки тому +32

    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 ;)

    • @siddharthrai9954
      @siddharthrai9954 2 роки тому +2

      tnx very helpful. Did not notice your comment first, almost wasted half day googling

    • @cornmasterliao7080
      @cornmasterliao7080 Рік тому +3

      my fxml file is in my class folder tho. there's no drop down.

    • @astrobaleno5866
      @astrobaleno5866 Рік тому +1

      @@cornmasterliao7080 same

    • @greekrapindustry
      @greekrapindustry 8 місяців тому

      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

    • @makif8360
      @makif8360 2 дні тому +1

      Thanks 🙏

  • @michaelk.6966
    @michaelk.6966 3 роки тому +1

    Один из лучших видеокурсов по JavaFX

  • @locky1827
    @locky1827 3 роки тому +2

    i have done it. Thanks. I from Russia and I like your videos about JAVA

  • @thedev5126
    @thedev5126 3 роки тому +6

    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;
    }

  • @abelxotessema343
    @abelxotessema343 10 місяців тому +2

    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.

  • @ctluwua7695
    @ctluwua7695 3 роки тому +2

    Only You helps me
    (Better Than my Teacher)

  • @felixnyamongo
    @felixnyamongo 2 роки тому +1

    Excellent tutorials. Bro is a good teacher💪

  • @xplane7879
    @xplane7879 3 роки тому +2

    I just clicked the ad to support you... 😍🙏

  • @Vladislav-w1o
    @Vladislav-w1o 10 місяців тому

    I like your videos. You are the best BRO

  • @amadoutraore1967
    @amadoutraore1967 6 місяців тому

    Thank you so much, your explanation is so clear

  • @amadeuss5600
    @amadeuss5600 3 роки тому +3

    I learn php first then go to java, i felt java way more structured than php.

  • @sam-williams1
    @sam-williams1 3 роки тому +1

    Thank you. You made this easy to understand.

  • @BroCodez
    @BroCodez  3 роки тому +10

    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);
    }

    }

  • @mohamedaliwalha4185
    @mohamedaliwalha4185 Рік тому

    Thanks a lot for your efforts, It helps a lot

  • @kole1678
    @kole1678 3 роки тому +9

    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
      @aohoang3215 3 роки тому

      in the middle of the screen is the point (0,0)

    • @jamesschmames6416
      @jamesschmames6416 3 роки тому +1

      @@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.

    • @jamesschmames6416
      @jamesschmames6416 3 роки тому +1

      I had been wondering the same thing. Watched through the video several times trying to see what I was missing.

    • @mdraiyaantarique1068
      @mdraiyaantarique1068 Рік тому

      @@jamesschmames6416 @kole1678 It's been 2 years now, do you remember the reason??? I'm stuck at the same place!

    • @Jack-cv7pl
      @Jack-cv7pl Місяць тому

      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

  • @prographicsstudio6313
    @prographicsstudio6313 Рік тому

    I learn a lot .tnx

  • @malikshahzaib3313
    @malikshahzaib3313 3 роки тому

    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.

  • @colemiller6032
    @colemiller6032 22 години тому

    Great!

  • @abelxotessema343
    @abelxotessema343 10 місяців тому +1

    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)?

  • @adityanaik3773
    @adityanaik3773 2 роки тому

    Nice Video bro ...

  • @MVL-be5eo
    @MVL-be5eo Рік тому

    Thank you very much! 👍

  • @gameGXT
    @gameGXT 2 роки тому

    Super Video

  • @rapbimsfrienda22
    @rapbimsfrienda22 2 роки тому

    Super explanation 😃

  • @longkesh1971
    @longkesh1971 Місяць тому

    Thanks bro.

  • @ashkanshakiba9579
    @ashkanshakiba9579 3 роки тому

    Useful 👌👍

  • @ijeomankem8029
    @ijeomankem8029 Рік тому

    Thanks bro helped a lot

  • @keanz3249
    @keanz3249 3 роки тому

    Im from Java tutorial just to see if you're still uploading, keep it up!

  • @erkanozel
    @erkanozel 3 місяці тому +1

    would you help to determine , maven pom file for this project , (java)thank you

  • @xxxxx3221
    @xxxxx3221 2 роки тому

    Great video, thanks!

  • @oettetteo4798
    @oettetteo4798 3 роки тому

    great videos!

  • @tomaszkarolak6179
    @tomaszkarolak6179 3 роки тому

    Thumb up, great work!!! ... as usual 😉

  • @boultifnidhal2600
    @boultifnidhal2600 3 роки тому

    Dude, i'm in love with these emojis hahaha ♥♥

  • @chemso_1
    @chemso_1 7 місяців тому

    da best

  • @chocodonuts3644
    @chocodonuts3644 Рік тому

    Thank you so much

  • @retr0k964
    @retr0k964 3 роки тому +6

    After coming from your Java swing tutorials, this SceneBuilder stuff feels like cheating? Am I cheating?

    • @ctluwua7695
      @ctluwua7695 3 роки тому

      No

    • @andromydous
      @andromydous 2 роки тому

      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.

  • @glenn8762
    @glenn8762 Рік тому +1

    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

    • @rectaalborween8471
      @rectaalborween8471 8 місяців тому

      If youve figured this out i'd like to know too :(

    • @rectaalborween8471
      @rectaalborween8471 8 місяців тому +1

      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 )

  • @wolanus
    @wolanus 3 роки тому

    Great video!

  • @ridaoutaleb
    @ridaoutaleb 2 роки тому

    Thank you.

  • @hamzachiguer642
    @hamzachiguer642 Рік тому

    thank you bro

  • @9thCrusade
    @9thCrusade 3 роки тому +1

    So does the scene builder replace the event handler method with the one we provide?

  • @Hselit06
    @Hselit06 3 місяці тому

    What is the difference between using swing and javafx

  • @skorpion9236
    @skorpion9236 3 роки тому +5

    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

  • @pratyushgangwar9747
    @pratyushgangwar9747 4 місяці тому

    thanks!

  • @omdharme5851
    @omdharme5851 3 роки тому

    Good

  • @shwetaborkar2312
    @shwetaborkar2312 3 роки тому +1

    Sir,please upload game devlopment course

  • @khaledeldingawy9234
    @khaledeldingawy9234 8 місяців тому

    thanks bro

  • @sarahashraf7329
    @sarahashraf7329 Рік тому

    thank you

  • @Magnezone962
    @Magnezone962 4 місяці тому

    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.

  • @daniloerdoglija4992
    @daniloerdoglija4992 3 роки тому

    Bro,you are legend :D

  • @Dswilsonangel
    @Dswilsonangel 2 роки тому

    Awesome!!!! Thanks!!!!!!! :)

  • @chrs-wltrs
    @chrs-wltrs 3 роки тому

    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?

  • @HaHoang-ly9hw
    @HaHoang-ly9hw 3 роки тому

    niceeeeeeeee

  • @jofafs
    @jofafs 11 місяців тому

    thanks bro!

  • @aryansudan2239
    @aryansudan2239 5 місяців тому

    Error: JavaFX runtime components are missing, and are required to run this application how to solve please help IntelliJ

  • @malikshahzaib3313
    @malikshahzaib3313 3 роки тому +1

    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.

  • @Zero-ed1ji
    @Zero-ed1ji Рік тому

    Hey bro, thanks for the great lesson, but mine has a little error it goes to Java Lang error

  • @ctluwua7695
    @ctluwua7695 3 роки тому +1

    From Where you learned programing ?

  • @pmatheus
    @pmatheus 3 роки тому

    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?

    • @sable1334
      @sable1334 3 роки тому +1

      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.

  • @freedom-jt8ot
    @freedom-jt8ot 2 роки тому +1

    how can do it without using sceneBuilder?

  • @vaibhavpal148
    @vaibhavpal148 3 роки тому

    what should i learn swing or javafx?

    • @jamesschmames6416
      @jamesschmames6416 3 роки тому

      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.

  • @paulmvubu3837
    @paulmvubu3837 2 роки тому

    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

  • @heyjoe5048
    @heyjoe5048 3 роки тому

    subscribed!

  • @andromydous
    @andromydous 2 роки тому

    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.

    • @bishnudas3562
      @bishnudas3562 2 роки тому

      no i am using mx linux it works smooth, but facing issue that scene builder is not showing controller class in dropdown

  • @thehobbyshop392
    @thehobbyshop392 3 роки тому

    Can I print a variable as a label in SceneBuilder?

  • @tonalddrump9391
    @tonalddrump9391 3 роки тому

    How about using Social Media?

  • @hippiestafarii
    @hippiestafarii 2 роки тому

    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

    • @hippiestafarii
      @hippiestafarii 2 роки тому

      I found it : my id name was not the same that the variable name grrr !!!

  • @royalsquad3992
    @royalsquad3992 2 роки тому

    gg

  • @andreray1795
    @andreray1795 Рік тому +1

    my circle is null '-'

  • @dmitryabramov1483
    @dmitryabramov1483 3 роки тому

    Привет, тебе!

  • @hamet1234
    @hamet1234 3 роки тому

    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

  • @Monster33336
    @Monster33336 3 роки тому

    Is JavaFX better easier than Java?

  • @walkmanofwar267
    @walkmanofwar267 2 роки тому

    bump

  • @jeffreyrobinnson1636
    @jeffreyrobinnson1636 2 роки тому

    Great Video!

  • @hasankhani6285
    @hasankhani6285 2 роки тому

    Good