How can i design proper java swing mvc design - is this mvc design example right? -
i designed controller class in mvc below.
public class controllermr implements observer { modelmr modelmr = new modelmr(); panelmr vpanelmr= new panelmr(); public controllermr() { this.modelmr.registerobserver(this); this.vpanelmr.registerobserver(this); }
when instantiate controller class, create model , view class. view here swing panel. illustration add together panel tab or frame in view.
i connect controller model , view help of observer pattern. see in constructor, register controller model , view. there indirect connection observer pattern, , concurrency management more easy.
is design true , if wrong, should set view , model outer of controller class below
controllermr controllermr= new controllermr(); controllermr.setview(vpanelmr); controllermr.setmodel(modelmr);
and there modifications in controller class above design. illustration must alter constructor of controller class
thank much effort.
mvc used when want separate controller, model , view each other 1 (more or less) interchangable @ future stage, way doing means there cannot view or model without controller, advise create them separate each other , pass references instead while still keeping mvc-pattern
java
No comments:
Post a Comment