Java Reference
In-Depth Information
Figure 3-2.
The JTextArea MVC architecture
Sharing Data Models
Because data models store only the state information, you can share a model across multiple
components. Then each component view can be used to modify the model.
In the case of Figure 3-3, three different
JTextArea
components are used to modify one
Document
model. If a user modifies the contents of one
JTextArea
, the model is changed,
causing the other text areas to automatically reflect the updated document state. It isn't necessary
for any
Document
view to manually notify others sharing the model.