Java MVC & Composite Design Pattern With Internal Frames
Still wondering the best way to do Model-View-Controller Software Architecture, Do I pass the Controller into the View, or do I use the Observer Design Pattern and let the Controller Observe any changes/requests made by the view so we can update the model and redisplay that.......
I have A Main JFrame which will开发者_开发技巧 have JInternalframes, and i want to apply the MVC Architecture. Using just a normal Java Application
Kind of stuck on this any suggestions to limitations ect will help a lot.
Sorry For the confusion, didn't there was an web aspect that just uses Frame and Internal Frame
I have written a program with the MVC pattern last year but I can't seem to find the code atm, I DO recall that I used it with the observer pattern, so that the Controller listened to the View (so controller implements Observer, view implements Observable)
(note: I'm still a student so there may be some errors in my comments.. just trying to help though!)
Your Mainframe contains all the frames, therefore they are accessible to it. The internal frames should get their "father" frame in the constructor as a a parameter, and store it as a context variable.
That way you can use both: if you decide to pass controller (MainFrame), views (InternalFrames) can register on its event, or you can update view through your controller.
regarding your question , you should use the Observer Design Pattern. this is logically correct to let the Controller control the flow and update the view upon model change.
精彩评论