I have a Java project that I’m trying to implement with a model-view-controller design. I have the backbone of all of the components established. I’m having some trouble deciding on how to connect it all together, particularly the view and the controller.
I have a class called MainView that extends JFrame. I have various other classes that help make up the MainView each of which extends JPanel. As an example one of these classes is called ParameterView. Should I allow the controller to see each of these “sub-views” or should I let the controller only see MainView and have everything be managed through there?
Likewise with the model, should the model be managed through one overarching class?
Thanks!
In the context of GUI (Swing-like) application, the Model-View-Controller is more of a vague suggestion than a concrete design. The number of variants of this “pattern” is staggering and there is no one “proper” variant you should aim at. You can choose either variant that seems to support your current need (and feel free to change it as your app evolves).
That said, here are some pointers regarding the situation you’re describing