From the course: Java Design Patterns: Behavioral Part 1
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Creating the components for a Command pattern - Java Tutorial
From the course: Java Design Patterns: Behavioral Part 1
Creating the components for a Command pattern
- [Narrator] In this example, I've got a simple representation of a graphical user interface for viewing documents, I want to be able to add buttons in the GUI, and when they're clicked, I want certain actions to be performed on the documents. So for example, I want to create a Save button and when I click that save button, I want the document to be saved. Obviously in a real GUI, this would be a bit more sophisticated, but to keep this example simple, I'm just creating a button and a main method and calling the click method. However, I don't want the GUI or the button classes to hold the information about what happens when the buttons are clicked. I want to be able to define the look and feel in the GUI, but I don't want to define the functionality of the button clicks, because I want to be able to use this framework in other applications, not just for viewing documents but for other things too. So in other words, I…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.