The Model-View-Controller Architecture
2008-01-05 18:41:25 来源:WEB开发网Swing uses the model-view-controller architecture (MVC) as the fundamental design behind each of its components. Essentially, MVC breaks GUI components into three elements. Each of these elements plays a crUCial role in how the component behaves.
- Model
-
The model encompasses the state data for each component. There are different models for different types of components. For example, the model of a scrollbar component might contain information about the current position of its adjustable "thumb," its minimum and maximum values, and the thumb's width (relative to the range of values). A menu, on the other hand, may simply contain a list of the menu items the user can select from. This information remains the same no matter how the component is painted on the screen; model data is always independent of the component's visual rePResentation.
- View
-
The view refers to how you see the component on the screen. For a good example of how views can differ, look at an application window on two different GUI platforms. Almost all window frames have a title bar spanning the top of the window. However, the title bar may have a close box on the left side (like the Mac OS platform), or it may have the close box on the right side (as in the Windows platform). These are examples of different types of views for the same window object.
- Controller
-
The controller is the portion of the user interface that dictates how the component interacts with events. Events come in many forms ?e.g., a mouse click, gaining or losing focus, a keyboard event that triggers a specific menu command, or even a directive to repaint part of the screen. The controller decides how each component reacts to the event if it reacts at all.
- ››Model与UIControl之间的模型关系
- ››View与Frame的分离
- ››TheServerSide网站2009年最热文章
- ››The Netron Project For vb.net
- ››The engine behind Splitter Flash game : workin...
- ››The engine behind Splitter Flash game – first...
- ››The engine behind Splitter Flash game – new A...
- ››view-source,JavaScript看网页源码
- ››The Standard C Library for Linux
- ››The File System(文件系统)
- ››The Standard C Library for Linux:ctype.h
- ››The Standard C Library for Linux:stdlib.h