|
|
Part I JFC Architecture
- In This Part
- Introduction to JFC
- MVC Architecture
- JComponent
- JFC Programming Techniques
Chapter 1 Introduction to JFC
- In This Chapter
- The JFC 1.2 Extension
- Swing
- Drag and Drop
- Accessibility
In Java 1.0, user interfaces were created by using the Abstract Window Toolkit (AWT). The AWT provides a set of primitive user interface components. These include such elements as buttons, labels, and text fields; higher-level user-interface components such as lists and choice boxes; classes for creating frames and dialog boxes; and classes to support menus that may be attached to a frame. The AWT also contains an applet entry point.
The original AWT was a peer-based toolkit, meaning that each component created a peer that was implemented in native code for the platform on which the Java Virtual Machine (JVM) was executing. The peer in turn created a window in which the component was displayed. This process of requiring each interface component to create its own window makes the AWT classes difficult to port and proved taxing on system resources. It also led to a problem common among toolkits that target multiple platforms: the least common denominator problem. Toolkits that only support components available on all the targeted platforms lead to an inferior component set that doesnt meet the needs of serious application development.
The AWT also contains classes that are not directly user-interface components. These typically are support classes, including a rich set of AWT Layout Manager classes and geometry classes.
In Java 1.1, extensions of AWT components can be lightweight. A lightweight component is created by extending the AWT Component or Container class directly. With the introduction of lightweight components, the door was opened for pure Java lightweight component toolkits. Eliminating the requirement for native peers circumvents the least common denominator problem and means that the single Java implementation of a component can be used for all targeted platforms.
The JFC 1.2 Extension
To address the shortcomings of the AWT, the Java Foundation Classes (JFC) were developed. The development of the JFC was unique. JavaSoft provided developers early access releases of the toolkit knowing that the application program interface (API) was subject to change. The developers were asked to use the toolkit and provide feedback on the usability aspects of API for the toolkit. This process was repeated many times before the first official release, known as JFC 1.1 and Swing 1.0.
JFC 1.2 is an extension of the AWT, not a replacement for it. The JFC visual components extend the AWT Container class. Thus the methods contained in the Component and Container classes that AWT programmers are familiar with are still valid for JFC visual classes. This fact also ensures that classes written at the component or container abstraction level will work with JFC classes. A classic example of this is layout managers. A layout manager may be set for any container and arranges components. Since JFC classes extend these classes, layout managers will continue to work as they did with AWT classes.
The AWT user-interface classes are now superseded by classes provided by the JFC. The support classes often play just as important a part in JFC applications as they did in AWT-based applications. AWT support classes, those that do not create a native window, are not replaced by JFC classes.
JFC 1.2 consists of five major packages:
- Swing
- Pluggable Look-and-Feel (PL&F)
- Drag and Drop
- Accessibility
- 2D
Why the Name Swing?
Swing is the unofficial name of the Java GUI classes contained in the JFC. The story is that Swing got its name at the 1997 JavaOne convention in San Francisco. A planned demonstration of the new component set was to be set to music. A Swing team member, Georges Saab, voiced the observation that swing music was enjoying a comeback. He went on to suggest that swing would make a nice code name for the project. The slogan potential was not lost on the room full of engineers, including the very famous one provided by Duke Ellington in a popular song, It Dont Mean a Thing if It Aint Got That Swing. Thus the name Swing was adopted. The early releases of the component library were released under the code name Swing. Even though Swing components were officially added to JFC 1.1, the name Swing has persisted. This has led to the often quoted statement from the JFC project leader Rick Levenson, Its spelled J, F, C, but its pronounced Swing. The name Swing is also used for the package name of the JFC classes. |
|