Java Reference
In-Depth Information
several programmers and substantial expandability, the MVC pattern is a sure win. If the
project is very small in scope and will probably never be updated, the MVC pattern is probably
unnecessary.
Alternatives to MVC
The most obvious alternative to the MVC pattern is not to use it at all. A system can be
designed and implemented that tightly integrates the actual system functions with the user
interface. This will, of course, limit the flexibly of the GUI. All changes will directly impact all
areas of the system, since the system is basically one unit.
On some programming platforms, tight integration of the presentation and data tiers is
possible. Due to the event-driven nature of the Java platform, some aspects of the MVC pat-
tern are inherent in any user interface. All interface components produce actions, and there
are always classes that are created to deal with these actions. In this sense, the MVC pattern
is built in, but the programmer can choose to limit its effect and not use the full MVC archi-
tecture.
Swing and the Abstract Windows Toolkit
The previous sections emphasized some high-level methodologies of interface design. Most
of the ideas, such as the MVC pattern, are platform agnostic and apply to the architecture of
development projects, which can then be developed in almost any language. The next sec-
tions shift to a platform-specific approach using the Abstract Window Toolkit (AWT) and
Swing to explain methods of interface implementation on the Java platform.
Entire topics have been written on how to program with AWT and Swing. This section
offers only an overview of some of the basic concepts. For more complete coverage of these
topics, we recommend you read the tutorials available online at http://java.sun.com/docs/
books/tutorial/uiswing .
Layout Manager Overview
Component s (buttons, text areas, graphics, etc.) are added to Container s such as a JFrame ,
JPanel , or a JWindow . Containers use layout managers to specify how components should be
laid out within the container. Window and Frame containers use BorderLayout as their default
layout manager. This particular layout schema has some peculiar functionality you may want
to review.
First, the BorderLayout divides the container into five areas, as shown in Figure 8-5.
Figure 8-5. The areas of BorderLayout
Search WWH ::




Custom Search