Gamelan

 Top navigation
Navigation Links

EarthWeb sites:

 



Foundation Classes

The release of Sun’s JDK 1.2 brings with it little, if any, significant changes to the core Java language, but like the Standard Library in C++, the introduction of the Java Foundation Classes (JFC) attempts to stabilize and standardize the language for current and future development. With the JFC and the advances in the general technology supporting the JDK, Sun has made impressive strides toward its "Write once, run anywhere" philosophy.

Introduction

It almost feels as if Java has been around forever. So much has been written and spoken about Sun’s visionary language that the fact that it is a developing language is sometimes forgotten. Fortunately, Sun has proved to be a good parent and has successfully overseen the accelerated growth of the language. Now, with the JDK 1.2, Java may have reached a level of maturity where it has the opportunity to fulfill its goals and Sun’s ambitions.

With the 1.1 release, Sun overcame several flaws in the Java language, such as an outdated event handling model and the use of peers in the AWT, and introduced new features, such as support for Internationalization and RMI. The 1.2 release builds on these enhancements, moving Java forward providing developers with ever-increasing demands for more and more complex software.

Within the latest release, the JFC provides a comprehensive collection of collaborating components that go a long way to providing developers with the features they have been lacking. These features, discussed below, should allow developers to build both commercial and scalable systems that are future-ready.

Java Foundation Classes (JFC)

Building on the pioneering work of Netscape’s Internet Foundation Classes (IFC), the JFC provides a framework for developing more powerful applications without compromising Sun’s goals for Java’s portability. The JFC is actually five groups of component classes: the Abstract Window Toolkit (AWT), Java 2D, Accessibility, Drag and Drop and Swing.

Abstract Window Toolkit (AWT)

Now essentially a legacy component, the AWT here provides the foundation for Swing, including the Lightweight UI Framework and the delegation event model from the 1.1 release of the JDK. Furthermore, its inclusion provides a path for migration towards the far superior Swing.

Java 2D

This API provides a rich set of classes for advanced graphic and image manipulation, further extending the previous functionality of the AWT, and thereby empowering the graphical aspects of Swing.

Accessibility

This API makes it possible for assistive technologies, such as screen readers or voice recognition systems, to interact with components in the JFC.

Drag and drop

This API will allow drag-and-drop capabilities between Java and native applications, supported through the "Glasgow" model.

Swing

Clearly the most mature of the new JFC features, Swing provides a comprehensive collection of GUI components supporting a pluggable "look and feel" (L&F) capability, utilizing the Lightweight UI Framework from release 1.1, and implemented in 100% pure Java.

Clearly these five components of the JFC are intended to work together to provide a comprehensive, extensible, and future-ready development environment, utilizing 100% pure Java in order to ensure cross-platform portability.

Not surprisingly, Microsoft has chosen neither to promote nor support the JFC, instead developing its own framework, the Application Foundation Classes (AFC). Though in some ways more immediately accessible and on the surface more flexible, there are several inherent and fundamental deficiencies with the AFC: no support for the 1.1 event delegation model, poor decoupling of the application model and GUI, hence no MVC support, incompatibility with AWT, no inherent drag-and-drop support unless on a Microsoft platform, and not fully bean compliant [1].

Let’s Swing!

Not all GUIs are created equal. Developing an application for the Mac is different than developing one for either Motif or Win32. In the early days the AWT failed as it tried to generalize interfaces, tightly coupling the GUI to the application code through peer controls. Using the Lightweight UI Framework and the Model-View-Controller (MVC) pattern [2], with Swing, Sun can now provide an architecture with a pluggable look and feel (L&F) for any platform as required. As well as providing L&Fs for Motif and Win32, Swing 1.0 will also provide two Organic looks, as well as the default Metal L&F. (It is not expected that a Mac L&F will be ready for Swing 1.0’s release.)

Swing is implemented through some 250 classes and arranged into some fifteen packages covering such key areas as Accessibility and L&F. Many of these classes correspond closely to their predecessors in AWT, making migration to Swing relatively straightforward for the programmer. Each of the AWT components, such as Button, have a corresponding lightweight Swing component, i.e. JButton. Furthermore, Swing has a more comprehensive collection of GUI components, removing dependencies on third party component libraries, and providing newer interface elements, such as Tabbed Panes and Tree Views, which have been incorporated into most GUI toolkits recently. The base component, JComponent, also now includes additional functionality such as debugging support, tooltips, and keyboard event detection.

With all these new features, developers can now build advanced user interfaces independently of the underlying architecture or platform, or allow a L&F to be selected at run-time. Working on top of the other JFC components -- AWT, Java 2D, Accessibility, and Drag and Drop -- Swing provides platform independent behavior. Furthermore, Swing applications become future ready for any new GUI standards that might emerge and assist in platform porting requirements.

It is with this approach, Java comes closer to achieving Sun’s philosophical aim of "Write once, run anywhere," and making the cross-platform functionality of the language fully viable.

Other enhancements

The JFC is clearly the high-profile element in the JDK 1.2 release, but there are a number of other enhancements and changes that are equally important, particularly in key areas such as security and performance. Space prevents us from doing these areas justice in this article, but they deserve at least a few comments.

With respect to security, 1.2 has introduced an extensible, high-granularity access-control mechanism based on the concepts of "policy" and "permissions" that can be used in applets, applications, beans and servlets. There have also been advances in providing interfaces for manipulating certificates.

Performance seems to be a standard complaint for those critical of Java, but Sun continues to improve the JVM, now providing native thread support for Solaris and better heap management, thereby reducing garbage collection overheads. Advances in Just In Time (JIT) compilers are also gradually pushing Java towards the execution speeds of mainstream compiled languages like C++. Additionally, enhancements have been made in version identification, RMI, audio capabilities, and the introduction of Java IDL to provide CORBA functionality.

What’s next?

Despite political battles over the future of Java (and to the eternal irritation of some major computer companies), the language is clearly here to stay. As the technologies used in the Internet advance further and further, Java too will support these advances, while the JFC already provides an extensible framework that is future-ready. Using JIT compilers, such as HotSpot’s dynamic compilation technology, there is documented evidence of Java approaching the speeds of C++ [3]. These features should be seen in the soon to be available beta release of the JDK 2.x.

Conclusions

The JFC appears to finally give Java the platform from which to achieve its early and ambitious claims. The JDK 1.2 is not perfect, but Sun has shown us where it is going (not just today), creating a very tempting path to follow. The promise of "Write once, run anywhere," so often criticized for its arrogance, could soon be regarded as Sun’s victory cry.

References

  1. JFC vs. AFC: Which GUI toolkit should you use?

  2. Design Patterns: elements of reusable object-oriented software by Gamma, Helm, Johnson, and Vlissades. Addison-Wesley Publishing Co., 1995.

  3. Just In Time for Java vs. C++

Resources

  1. JDK 1.2 new feature summary

  2. JDK 1.1 new feature summary

  3. Java foundation classes

  4. JFC FAQ

  5. Java developer home page

Give them a visit

Give them a visit



HomeAbout UsSearchSubscribeContact UsFAQs
Use of this site is subject to certain Terms & Conditions.
Copyright (c) 1996-1998 EarthWeb, Inc.. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of EarthWeb is prohibited.

Gamelon File I/O Library

Gamelon® is a registered trademark owned by Menai Corporation and Gamelan is used under license from Menai Corporation by EarthWeb, Inc. Menai Corporation is the maker of Gamelon® cross-platform software for the Internet. The adjacent logo is a trademark of Menai Corporation.