Java Reference
In-Depth Information
Table 3-1. Swing Component Models (Continued)
Component
Data Model Interface
Implementations
JToggleButton
ToggleButtonModel
JToggleButton
ButtonModel
JTree
TreeModel
DefaultTreeModel
TreeSelectionModel
DefaultTreeSelectionModel
JTree.EmptySelectionModel
When directly accessing the model of a Swing component, if you change the model, all
registered views are automatically notified. This, in turn, causes the views to revalidate them-
selves to ensure that the components display their proper current states. This automatic
propagation of state changes is one reason why MVC has become so popular. In addition,
using the MVC architecture helps programs become more maintainable as they change over
time and their complexity grows. No longer will you need to worry about losing state informa-
tion if you change visual component libraries!
Summary
This chapter provided a quick look at how the Swing components use a modified MVC archi-
tecture. You explored what makes up this modified architecture and how one particular
component, the JTextArea , maps into this architecture. In addition, the chapter discussed the
sharing of data models between components and listed all the data models for the different
Swing components.
In Chapter 4, you'll start to look at the individual components that make up the Swing
component library. In addition, you'll explore the Swing component class hierarchy as you
examine the base JComponent component from the Swing library.
 
Search WWH ::




Custom Search