Reputation: 539
I'm creating my first "bigger" application in Java. As MVC is only pattern I know, I decided to use it. But there's something wrong with this concept.
For example. I need an Action
(or generally event) fired from 2 places (from Button
in frame and MenuItem
). It has to do changes in at least 2 places and in the model.
I've got some ideas, but they seem wrong:
Please tell me how to build it. Or give me some links to some easy to analyse applications.
Source of my project is here, if anyone wants to have a look: https://github.com/Arrvi/ColorExtractor
Upvotes: 1
Views: 1236
Reputation: 205785
You are correct to use Action
to encapsulate functionality for use by disparate components such as menus and buttons. A spectrum of examples is cited here. As regards MVC, recall that Swing uses a separable model architecture, examined here. In effect, the user is the controller, and not every interaction needs to pass through your application's controller.
Upvotes: 1