Navigation Bar

Column Head: About Swing

Column Heading: Component APIs

Heading: App Service APIs

Heading: Miscellaneous

Heading: Pluggable L&F APIs

Download Swing Swing JavaDoc APIs JDK 1.1.4 Documentation
JDK 1.1.4 Download
JFC Web Site README

Head: Feedback


Page Heading: Swing Overview - 2

This Overview is divided into two parts. The first part introduces the Swing component set, lists and explains the goals that Swing's designers had in mind when they started work on the project, and shows how those goals were met. This part of the Overview introduces:

  • The pluggable look and feel (L&F) features that are built into Swing components
  • The model-view-controller (MVC) architecture that the Swing design team used to give Swing components their pluggable look and feel
  • The delegate, a mechanism that the MVC design uses to give components the pluggable L&F capabilities
  • The drag-and drop capabilities that are built into Swing components
  • A quick look at a few other important capabilities of the Swing component set.


Head: Pluggable Look & Feel

One of the most important features of Swing components is their pluggable look and feel design, which increases the reliability and consistency of applications and applets deployed across platforms. The pluggable L&F design of the Swing component set provides an easy yet powerful mechanism for individualizing an application's visual personality without having to subclass the entire component set used in the application.

By taking advantage of Swing's pluggable L&F capabilities, you can make it possible for users of your application to switch the look and feel of the entire application's graphical user interface at runtime. To switch from one L&F to another, users don't even have to restart your application. That means that users can always work with a GUI that is familiar to them, no matter what kind of computer they they own, and no matter what kind of computer they are using.

This capability is particularly important for users of network computers (NCs). With Swing, a user of an NC can select the GUI that she or he likes best instead of having to settle for the GUI that's provided by a particular NC's operating system.

The first product release of Swing includes support for two look-and-feel implementations. One of these implementations, called the "Basic" look and feel, produces components that have a Windows kind of look. The other one has the IFC-style look that is familiar to Netscape users. Swing's pluggable L&F capabilities allow other L&Fs to be designed with a minimum of effort whenever the need arises.


Head: The MVC Design

Diagram: View/Controller/ModelThe architecture of Swing components is based on a well-known object-oriented design structure for GUI components called the model-view-controller, or MVC design. When a GUI component is developed using MVC architecture, it is divided into three parts:

  • A model -- An object that defines the component's state
  • A view -- The visual screen representation of a component
  • A controller -- An object that controls a component in such a way that it responds to user input.

You really don't have to know anything about if you just want to create and use simple components. But if you want to take advantage of the MVC-based design of Swing components, it can provide your components with tremendous versatility and easy-to-use cross-platform capabilities.

The MVC-based design of Swing components is described in more detail in the next document in this set, "Swing Architecture."



Head: The Delegate

Picture: Delegate (Man With Briefcase) A vital part of Swing's pluggable L&F mechanism is a user-interface (UI) object called a delegate. This delegate -- the "VC" portion of the MVC design -- provides designers of Swing components with the kind of flexibility that it takes to create GUI tools for an ever-increasing set of platforms, ranging from mainframes to small personal digital assistant (PDA) devices.

The delegate even provides Swing components with hooks to simplify the testing of components and make them more easily accessible to users with special physical needs.

For more information on how the delegate works in a Swing component, see the specification titled "The UI Factory."


Head: Drag and Drop

The Drag and Drop specification is available in the JDK 1.1 documentation and will soon be released as an update to both JFC and Swing. Drag and Drop (D&D) functionality as part of the core JFC class library. That means it will be available on all Java platforms in a consistent and supported fashion. It will significantly improve application interoperability by enabling D&D between Java applications and non-Java applications.

The generic, platform-independent implementation of D&D will enable objects to be dragged and dropped from one application to another. This update will support D&D between two Java applications, but more important, it will support D&D between a Java application and a native application. This means that a user running the application on UNIX will be able to D&D to a Motif application and then run the same code on Adobe Windows and D&D to native applications running there. D&D support makes it much easier to introduce Java applications to the enterprise.

Swing includes Pure Java D&D in the short term, and native integration for Drag and Drop in JDK 1.2. Swing's drag-and-drop capabilities are examined in more detail in the specification titled "The Drag and Drop API."


Head: Other Features of Swing

Along with the features outlined in the preceding section, the Swing component set provides support for:

  • Timers -- Swing supports a timer class designed along the lines of the AWT's Timer class -- that is, a timer that can queue events which run on the event-dispatching thread).
  • Event-queue enhancements -- The Swing set includes support for per-application or per-applet event queues. Local event queues will allow secure (destructive) access to the contents of the queue. For more details, see "The Swing Event Queue."
  • Keyboard navigation -- Windows users are familiar with keyboard shortcuts -- a feature that lets you substitute keystrokes for the mouse actions that are used to execute menu commands. Swing supports not only menu-related keyboard shortcuts, but other kinds of keyboard navigation as well. In fact, Swing offers as much support as you're ever likely to need to control a user interface (UI) from the keyboard. (As Swing development continues, this feature is being coordinated with the accessibility team).

Left Arrow


Version 0.5. Last modified 10/1/97.
Copyright © 1995-97 Sun Microsystems, Inc. All Rights Reserved.

Sun Logo