 So far, our GUIs have been pretty one-dimensional, pretty bland. And the reason why is because we haven't actually developed sort of that interaction. We develop a GUI because we want the user to be able to do something with our program. And so if we think about something like simply a button, let's say for example, I'm looking at a panel and I see a button that says OK, and I see another button that says Cancel. Well, both of these buttons, both of these buttons have actions to them. Both of these buttons are objects. However, they both have a different action. Cancel should disable the changes that were made in whatever window I'm doing. OK should apply those changes to kind of the program, the configuration. So what happens is I now have to sort of create this interaction with each one of these buttons. I actually have to create the action for what happens when I hit the OK button. I have to create the interaction when I hit the Cancel button. And to break this down, what we look at are sort of the three components of what we call event-driven programming. The first one is simply the object, the source of what we would consider our event. When I click on the OK button, I'm clicking on specifically the OK button, not the Cancel button. So we could consider the OK button my source. But then we get into sort of the other two factors of it. And that's actually where we start to look at the idea of an event. So again, we think of this as my OK button. But what does it mean to kind of interact with that button? Say for example, I click on the button. Well, maybe I don't want to just click on it. Maybe I want it to turn red when I hover over it. That's technically an event. I've hovered over it. I've moved my mouse into it. So that's actually its own style of an event. What happens when I do click on it? Well, there's an action there. Say for example, instead of a button, what if I was talking about just a traditional window paint? My program's paint, you know, this guy right here. And I wanted to track as my mouse moved across the screen. Well, that in itself is an event. So that's this guy. That's my action. But again, when I click on a button, if I, say for example, pull up some working code right now, and I run this, what I'm going to see is a 250 by 250 button. That when I click, nothing happens. So I'm giving it this action, but I don't have anything handling that action. And that's actually where we develop what is known as an event handler. Now what we can do is we can actually create a new class that implements this event handler interface. And so if we do that, what we get is a single method. That single method is an abstract method. It's called handle. And that handle method, that's actually when we start to make our button do something. So if we took that same code as before, and I came in here and I added in a class button handler, which implements again, the event handler action event, which is the clicking of the button, and if I spell implements correctly, again, all right, well, one of the things that we see is, oh, I have to import again. So all of a sudden, I have to import the event handler from Java FX, just like I did with my button and my scene and my stage, all these things I have to implement for Java FX, I have to implement and import my event handler. So again, like I said, this action event, well, let's see, I'm going to do something that you really shouldn't do, but I'm going to change event handler to a star. That's just going to get rid of a lot of things. Now you see that it's saying once again, I got a red squiggly, the button handler must implement the inherited abstract method. We're talking about that handle method that I was just talking about. So I'm going to click on the add the unimplemented methods, which is again the handle method. And so now what we're saying is whenever you click on the button, do this handle this event. And so simply I'll just come in here and do a system.out.println, okay, button pressed. That's it. Now when I run this, you can see I'll pull up with the same screen, but as soon as I hit okay, take a look down there. Why didn't you? Okay, so here's actually a great example. So I've created this handler. I've created my button. Where in my code on what line am I telling my button to actually implement this handler? I've developed it, but where am I explicitly stating to make it for my okay button? I'm not. That's actually what I need to implement next. I need to come in here and right after my btn okay has been created, I need to actually sort of put it together. To do that, I come in and say btn okay dot. And this is actually where we get a little bit of a thought process. What we have to do is think about all the different actions that we can talk about. Well, action, that's a very powerful world. Let's actually see what happens when I go to set. Well, we don't see any set action, but set on action. Notice that's the first thing that appears and look inside there. Its parameter is expecting an event handler, something that we just implemented. So if I come in here and set that up, I can come in here again and I can actually do a few things. I'm going to go ahead and just type in new button handler. Now what I've just done here with this new button handler, I could have gone in and I could have created this beforehand like we've done in the past. I could have came in and said button handler handle equal new button handler and then come in here and I could have said oh handle it works perfectly fine. All I did is I took out that middle man. I took out the fact that I don't need this handle, this class that I'm creating solely for this button. I don't want to recreate it. I don't want it for later use. I just want it once, so I'm only going to deal with it once. I save this, I compile it up. Once I see my button, as soon as I hit OK, the OK button has been pressed. One little nice little thing just before I go is if I add in, say for example, a public static, I'll just go public and count equals zero. Every time I hit my button, I'm going to keep track. Press plus count plus times times with parentheses because obviously I might never press it. Now I run this, I'm going to hit OK. It's been pressed one time. It's been pressed two times, three times, four times, five times, six times, seven times. You get the picture. So it's a way for me to now interact with my program.