Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Java Swings/MVC

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

right This chapter explains how to separate Swing applications into a more maintainable triad of components: the domain model, the view of the user interface, and the controller that oversees these. A minimal class structure is shown below. center|600px The main application class is the controller: it creates a model object (which is Observable), and a view object (which is an Observer of the model). The controller adds the view as an observer of the model. When the model changes, it calls setChanged() and then notifyObservers(). This means that the model can react to user input. The controller doesn't touch the view (apart from instantiating it and giving it the model). The view has access to the model, including to change it.