Because each Swing component is rendered by Java code rather than by platform
specific peers, it is possible to separate the look and feel of a component from the logic
of the component, and this is what Swing does. Separating out the look and feel
provides a significant advantage: it becomes possible to change the way that a
component is rendered without affecting any of its other aspects. In other words, it is
possible to “plug in” a new look and feel for any given component without creating any
side effects in the code that uses that component.
Java provides lookandfeels, such as metal and Nimbus, that are available to all Swing
users. The metal look and feel is also called the
Java look and feel. It is a platform
independent look and feel that is available in all Java execution environments. It is also
the default look and feel. For this reason, the default Java look and feel (metal) is used
by the examples in this chapter.
Swing’s pluggable look and feel is made possible because Swing uses a modified version
of the classic
modelviewcontroller (MVC) architecture. In MVC terminology, the
Dostları ilə paylaş: