 So we're starting to complicate things a little bit more. I've added in a second class. I'm implementing an event handler and well I'm I'm kind of disjointed all over the place. I'm making new button handlers on the fly Well, one of the things I can do is I can actually sort of reduce the amount of Work I'm doing here again if we think about this button handler the reason why I'm doing new button the handler Inside of set actions because you know, I only care about my BTN okay happening I don't want you know my BTN cancel doing the exact same thing and for our sake. Let's say I do that I I bring in another Button I bring in a cancel button that says cancel and I'm gonna need to implement this into a pain so new pain Why not I'll just make it an H box that'll make things a little smoother on our round so a horizontal box H box boom and I'll go ahead and implement that so import And let's see. I'll just I know I'm so bad have it's just people are probably screaming at me to no You shouldn't be importing the stars So again now I gotta come in here and pain it that get children that add all BTN okay BTN cancel So again, I've only just added in a second button now. It's not gonna Span my entire window, but again, I've got my ok button and it still has the ok button on it My cancel does not and again, that's because I don't want cancel to have any interaction with my okay So one of the things I can do is instead of doing this new Button handler and then having button handler down here is I can actually create what is known as an anonymous Inner class this anonymous inner class what I'm actually doing is I'm reducing the amount of Disjointedness the amount of typing I have to do all over the place now to do this What's actually going to happen is basically? All of this stuff right here that I've highlighted out. I'm actually gonna cut that out. I'm gonna by cut I mean control X And I'm gonna get rid of those three lines right there Now again when I've cut that it's stored in my clipboard right now I'm gonna come in here, and I'm actually gonna get rid of button handler Now what was button handler if we take a look at all that again? Button handler was me just saying oh a button handler implements this abstract class that I then Build right there on the fly. I override the handle method. I threw an account all that stuff So what I'm actually gonna do is I'm gonna say well That's the case Let me just kind of get rid of this And let me just build it on the fly and So now all of a sudden I come in here, and I'm gonna build this event handler now One thing I do have to do is I do have to tack on those guys I do have to tack that on because remember when I do a new I'm basically saying invoke this construct Well, guess what event handler has a constructor as well even if it's an interface And so I'm coming in saying event implement the empty No art constructor in which I then also make a new variable called count that exists inside of this temporary on the fly class that I've just built and also Override the handle method now again this guy down here Don't need them anymore notice nothing's airing out nothing's freaking out over here and When I run this just to clean this up a little bit. I Get the exact same effect. I hit okay So what I've done is I've removed Reduced the amount of typing I can do and what this is nice for is I can then come in here and maybe copy Paste it and do the exact same thing with cancel because again if we think about it What are these classes these buttons doing well? I want to reduce the amount of work. I have to do all over the place again, I don't want to have to make a BTN okay handler a BTN cancel handler, especially when that's all it's doing is it's just implementing this one Method and it's just keeping track of what they are doing So now once I've done these anonymous inner classes I can hit okay, and I still get the okay button hit one two three four five times And then I can come over here to this cancel button and guess what because I'll be just implemented the same thing set on action new event handler action event Cancel button was pressed once twice three times