View RSS Feed

Java Swing

Component Architecture and MVC

Rate this Entry
by , 04-26-2012 at 08:46 PM (723 Views)
MVC’s common variation is used to present components by Swing where controller and view get combined to form an object known as delegate. Delegates present model and also translates the input of user into model, just like it is done by a controller. Communication that takes place b/w controller and view is found to be very complex. Two simplifies are combined, for the component design.

For example, checkbox widget shall be considered. It consists of a state which could be true or false. It corresponds to model of the checkbox. The way two states are presented at screen basically refers to delegate view. When mouse clicks at the checkbox then delegate controller would be responsible to notify intended state change’s model. Delegate that is linked to checkbox use check box so that to present the “true state”, and unchecked box for presentation of the “false state”. State is toggled when you click in box. Delegate view would be reflecting the model and delegate controller would be translating user’s input to model.

JComponent has subclasses known as Swing widgets, such as JButtons. At anytime, there is one model of JComponent and one delegate is linked to it. A particular JComponent’s possible models make implementation of model interface possible, specifically to JComponent. ButtonModel interface shall be implemented for class which is considered as JButton’s model. Similarly, delegates are the delegate interface implementations which are specific to JComponents. JButton delegate is defined by the ButtonUI interface.

Submit "Component Architecture and MVC" to Facebook Submit "Component Architecture and MVC" to Digg Submit "Component Architecture and MVC" to Submit "Component Architecture and MVC" to StumbleUpon Submit "Component Architecture and MVC" to Google