JavaFX Java GUI Tutorial – 2 – Handle User Events

Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –






42 responses to “JavaFX Java GUI Tutorial – 2 – Handle User Events”

  1. Protocycle_X Avatar

    what does "this" refers to in 3:35? like, what is it passing? "button" itself? the "handle" method? or is it calling "handle" using "this" because it is the only handle method that there is so far (if so, how does the compiler know that "this" == "handler"?)? D:

  2. Cilicili Bubu. Avatar

    Mean call the same class method which is handler ?
    What if i do another class and all event method is inside ?

  3. Marc : Avatar

    hey man, thanks for your videos. Starting to learn about new coding features can be pretty daunting. There is a whole lot to learn and most of it is about semantics; many times there is a pretty easy to understand logic behind new methods and classes that ends up clouded by technicalities or arbitrary namings. Personally, most internet tutorials/explanations do a pretty bad job at providing a clear explanation of even the simplest methods. Your videos are exceptional. It may have to do with laundry basket. Anyway, thank you. 🙂

  4. shashuri Magrease Avatar

    Bucky sama you totally rock

  5. Em Kej Avatar

    Best intro I've ever seen 😀

  6. MetalFortress Avatar

    Thumbs up for the story in the beginning xD

  7. Daniel Pan Avatar

    I do weird things when I'm alone

  8. Mark Davis Avatar

    Hahaha, I didn't expect that output. So good! Thanks 🙂

  9. sherlock omar Avatar

    God im in love with your tutorials. thanks a lot

  10. Jack Sparrow Avatar

    4:35 You are comparing objects using == DONT DO THIS USE .equals() !!

  11. Hamza Nasir Avatar

    I thought JavaFX's GUI is made on XML (like in android studio). Was I wrong?

  12. APRIL Paxton Avatar

    If I put the method in another class named A, what will be filled instead of "this" ?

  13. Taiitoo Avatar

    I came here for the story

  14. Mister Voldemort Avatar

    lol laudry basket on the head haha!

  15. Donal Moloney Avatar

    what would u write if u wanted the source of the even to be a mouse click

  16. Logan Stanfield Avatar

    I like the lines you print.

  17. Guneet Singh Avatar

    ooo i love it when u touch me there

    SAVAGE !

  18. fernando espiritu Avatar

    Good video, but I don't speak English and anyway I'll see your videos XD

  19. Chocolate Storm Avatar

    by far the most engaging intro on youtube

    better than all those 3d dubstep intros

  20. chuckles de clown Avatar

    so the button prints in the command thing where basically everything's printed but how do i make a text box and have it print there?

  21. Min3vidz Avatar

    You shouldve waved to your neighbour 🙁

  22. Pyromaniac Avatar

    I love it when the bed is JRHNBR

  23. Monsterc Breakc Avatar

    seems easier:
    button.setOnAction(e -> {

  24. Terran Republican Avatar

    Bucky has a bucket on his head, oh.

  25. Dave Morris Avatar

    +1 for the story =)

  26. Wolfteam IS Avatar

    The most simple and clear ecplination i found so far. been stuck in this problem for a week and finally you are a hero!

  27. Zocken mit Ice Avatar

    So i just came here to learn about java fx and hear a great storry… 11/10 Would come again 😀

  28. Barış BAYRAMOĞLU Avatar

    Thanks for video dude 🙂

  29. Pavlos Nicolaou Avatar

    This jokes at the beginning of these videos are just great xD

  30. Tom Avatar

    button.setOnAction(this) doesn't work anymore in javaFX 8. (java SDK 1.8)

    When you define the method public void handle(ActionEvent event) { //… }

    Java can't find the right method you're looking for by just calling to this in the setOnAction property.
    So in order for java to find your handle method within your class, you need to express this::handle in the setOnAction property.


    Java needs to know what method you're refering to when you're using this.
    You also don't need to @Override the method anymore when you're expressing this::handle

    Otherwise if you're using a lambda expression.
    You need to do this:

    button.setOnAction(event -> {
    System.out.println("Fuck man, this tutorial is already outdated as fuck");

    or create a new method handle within the property of the .setOnAction();

    button.setOnAction(new EventHandler<ActionEvent>() {
    public void handle(ActionEvent event) {
    System.out.println("Fuck man, this tutorial is already outdated as fuck");

    If using multiple buttons, you naturally need to tell to java which button you're calling to, or create different methods for each button. This is just an example on how to do it in Java 1.8.
    Sorry if I don't use the correct naming for properties, methods, objects, class or whatever. English is not my native language, we give different names to somethings in my language and are not sure what the correct ones to use are in English.

  31. つんつんちゃん Avatar

    OOooooo i love it when u touch me there…..

  32. nuno sofyen Avatar

    Music song = new Music ();
    song.title("If my lecturers were like you");
    song.setLyrics (" Once I'm bored and I want to learn something new .. you are always there for me … etc");
    Instrument instrument = new Instrument ();

  33. youpwnt Avatar

    Very bad programming style. First: Never compare objects using "==", use the equals-method instead. Using "==" doesn't guarantee that the object ist the button you were looking for. Second: Don't implement the EventHandler in your class, create one and pass it to the button (using an anonymous or named inner class).

  34. McLovin McBabies Avatar

    what an intro xD <3

  35. rickdps Avatar

    Thanks man…I really appreciate it …

  36. Andrew Nelson Avatar

    bucky is the best

  37. keith harris Avatar

    LOL hey Bucky were you smoking at the time;-) keep up the good buddy you make more sense than the lecturers at Queens. veryMatureStudent(String name, String dob){…}

  38. Bruno César Avatar

    Hey man, where is the code of all the JavaFX Java GUI Tutorial list videos?
    Thankx for all this material.

  39. Ferdi Vefa Avatar

    Nice video. Thnx.

Leave a Reply

Your email address will not be published. Required fields are marked *