Sun Java Solaris Communities My SDN Account
 
Java Platform, Standard Edition (Java SE)

Java Foundation Classes (JFC) Overview

 
API Specifications
Documentation
FAQs
 
Books & Authors
Forums
Bug Database
 
Online Sessions & Courses
Tutorials & Code Camps
Quizzes
 
 
Contents
 
Overview of Java Foundation Classes (JFC) Features
Choosing Between HTML and Rich Client: One Size Does Not Fit All
Deploying JFC Applications on the Web: Applets or Applications
Building Rich Clients for Web Services: Bringing Interactivity to the Web
JFC/Swing: Interacting with the User
Pluggable Look and Feel: Adapting to User Expectations
Java 2D: Producing Eye-Catching Visuals
Printing: Putting It on Paper
Abstract Window Toolkit (AWT): APIs for Integrating with the Desktop
Drag and Drop: Accelerating Data Transfer
Accessibility: Supporting People with Disabilities
Internationalization: Supporting Users World-Wide
Input Method Framework: Accepting Text Input from Eastern Languages
 
Overview of Java Foundation Classes (JFC) Features

Abstract Window Toolkit (AWT) - APIs that enable programs to integrate into the native desktop window system, including APIs for Drag and Drop.

Java 2D - APIs to enable advanced 2D graphics, imaging, text and printing.

Swing GUI Components - APIs that extend the AWT to provide a rich, extensible GUI component library with a pluggable look and feel.

Accessibility - APIs and assistive technologies are for ensuring an application is accessible to users with disabilities and meets government requirements for accessibility.

Internationalization - All JFC technologies include support for creating applications that can interact with users around the world using the user's own language and cultural conventions. This includes the Input Method Framework API.

These five technologies are designed to be used together to enable you to build fully functional GUI client applications that run and integrate on any client machine that supports the J2SE platform, including Microsoft Windows, Solaris, Linux, and Mac OSX.

Note: The most recent release containing JFC API is Java 2 SDK, Standard Edition, (J2SE) v 1.4 and is available for Microsoft Windows, Solaris, and Linux. Visit www.apple.com/java to find the latest information on J2SE platform support for OSX.

 
Choosing Between HTML and Rich Client: One Size Does Not Fit All

When you're choosing a technology to construct GUI client programs, it's important to choose one that best fits the goals and parameters of the project. This is particularly true when deciding between authoring an HTML-based Web client and a traditional client application (such as a JFC client). Each client type has its place. Many factors play a role in this decision, including the technical expertise of your development team, market trends, and legacy code. However, one of the most important considerations should be the user experience your client will provide, as this may ultimately be the deciding factor in whether your customer chooses your product or your competitor's.

Since JFC clients can also be deployed over the Web, Web access should not be the sole deciding factor. The following guidelines can be used to make the choice based on how the user needs to use your client to get useful work done.

HTML clients are particularly good in the following circumstances:

  • The application must collect form input from the user and requires little interactivity.
  • The use model fits a "wizard" style, executing a well-defined sequence of steps.
  • The application is used on an infrequent or ad hoc basis (less than an hour per day).
  • The user requires ubiquitous browser access and cannot rely on dedicated client machines.
  • The application never needs to be used offline.

Rich clients should be considered in the following scenarios:

  • The user requires direct-manipulations of data or must perform significant editing operations.
  • The user needs to input international characters not supported on the keyboard and cannot rely on the browser's support for input methods.
  • The application is used frequently (more than an hour per day).
  • The application should or must be usable off-line.
  • The application needs to perform computations that can be handled more efficiently in the client (rather than requiring constant roundtrips to the server).

Although most people tend to associate "Web" clients with HTML, it's important to understand that "Web" applications can also be built with J2SE technology, since JFC applications can be both easily deployed over the Web and can communicate over the Web using HTTP APIs in the J2SE platform. (We demonstrated this at our JavaOne 2000 talk, Building JFC-based WebAwareWare.

Fortunately, regardless of which client type is more appropriate for your project, there are Java technologies for both. The Java 2 SDK, Enterprise Edition (J2EE) platform includes the JavaServer Pages technology, which makes it easy to construct dynamic content on the Web, including HTML clients. The J2SE platform provides the JFC APIs for building rich, Web-deployed clients. Either way, it's Java technology.

 
Deploying JFC Applications on the Web: Applets or Applications

J2SE client programs can be easily deployed over the Web as either applets or applications. Applets are programs designed to run within the bounds of the client Browser window and typically run in the same process space as the browser. Applets are deployed into todays browsers using Java Plug-in technology.

Java applications are programs that do not run within the browser, but instead run in their own process space as standalone applications. However, they can still be easily deployed over the Web using a technology called Java Web Start.

In considering whether you should write an applet or an application, consider the goals you are trying to achieve with your client. If you need to provide a user experience that integrates closely with the browser and intend to display your GUI within an HTML page, then an applet is likely the right choice. If your program will be popping up indepdenent top-level windows and does not need to integrate directly with the browser, then a Web-started application is the right choice.

 
Building Rich Clients for Web Services: Bringing Interactivity to the Web

Web services technology has emerged as the next programming paradigm for getting work done on the Web. The Java 2 SDK, Enterprise Edition (J2EE) platform is a foundation for creating the server side of Web services with products like the Java Web Services Developer Pack. Equally exciting is the potential for building rich, interactive Java technology-based clients for these Web services, and the JFC technology, together with the XML technologies in the J2SE platform, is perfectly suited to this task.

JFC technology provides advantages over other client technologies because:

  • It runs on all the client devices and desktops supported by the J2SE platform, including Microsoft Windows, Mac OSX, Solaris, and Linux.
  • It supports creating fully-featured, interactive, graphically rich, internationalized clients, providing a more compelling user experience than traditional Web clients.
  • It's Java technology, which provides seamless and powerful access to XML data and SOAP messaging functionality in the client.

"Rich Clients for Web Services" has been a major theme at the last few JavaOne conferences. Visit the PDF conference slides for these presentations at Rich Clients for Web Services (The Sequel), JavaOne 2002 and Rich Clients for Web Services, JavaOne 2001.

 
JFC/Swing: Interacting with the User

The Swing toolkit is a fully-featured UI component library implemented entirely in the Java programming language. The J2SE platform's javax.swing package uses the windowing functionality of AWT and the rendering capabilities of the Java 2D API to provide sophisticated and highly extensible UI components that comply with the JavaBeans specification.

The Swing UI components are categorized below:

Atomic controls

JLabel, JButton, JCheckBox, JRadioButton, JToggleButton, JComboBox, JScrollBar, JSeparator, JSlider, JSpinner, JProgressBar

Complex data components

JTable, JTree, JList, JFileChooser, JColorChooser, JOptionPane

Text components

JTextField, JFormattedTextField, JPasswordField, JTextArea, JTextPane, JEditorPane

Menu components

JMenuBar, JMenu, JPopupMenu, JMenuItem, JCheckboxMenuItem, JRadioButtonMenuItem

Layout containers

JPanel, JScrollPane, JSplitPane, JTabbedPane, JDesktopPane, JToolBar

Top-level window components

JFrame, JDialog, JWindow, JInternalFrame, JApplet

The Swing components use other JFC features, such as drag and drop, the accessibility APIs, and the J2SE platform's internationalization support to create fully featured UI functionality out of the box.

Swing also includes the javax.swing.text package, which contains support for implementing sophisticated styled-text rendering and editing, as well as support for rendering and mutating HTML documents.

To get more detailed technical information on using the Swing APIs, visit The Swing Connection. For a guide to programming with the Swing APIs that includes dozens of complete examples, visit The Swing Tutorial.

Demo
If you have a 1.4 Java Runtime Environment and the Java Web Start product installed, you can run the 1.4 SwingSet2 demo. It showcases many of the Swing components.

 
Pluggable Look and Feel: Adapting to User Expectations

Finally, Swing supports a feature known as the Pluggable look and feel. This enables the Swing GUI components to support different look and feels while maintaining a consistent API for the component, allowing developers to code their application GUI once and run it in multiple look and feels. In the J2SE platform, Swing provides a Java technology look and feel that is consistent across platforms (the default), as well as native-platform look and feels for Microsoft Windows and Motif (Linux/GTK is in the works). Apple provides their own Swing Aqua look and feel for Mac OSX. Applications can choose between running the Java technology look and feel or picking up the appropriate platform-native look and feel at runtime.

Native Windows Look and Feel
supported on Microsoft Windows only
Native Mac Look and Feel "Aqua"
implemented by Apple and supported on Mac only
Java Look and Feel "Metal"
supported on all platforms
Motif Look and Feel (Solaris & Linux)
supported on all platforms
These screenshots were taken from Borland's JBuilder IDE, which takes advantage of the cross-platform feature of J2SE and JFC to support their product on Microsoft Windows, Mac, Solaris and Linux.

The Swing Pluggable look and feel API is designed to be extended so that developers can create custom look and feels. This is sometimes desirable to achieve a particular branding for an application. To see some examples of custom look and feels, see Kunstoff and Alloy Look and Feels, L2F's look and feels, and Compiere.

 
Java 2D: Producing Eye-Catching Visuals

The Java 2D API is a set of classes for advanced 2D graphics, imaging and printing. The API combines support for line art, text, and images into a single comprehensive model. The capabilities of Java 2D enable programs to produce jaw-dropping visuals.

The API provides extensive support for image compositing, coordinate transformations, a set of classes to provide accurate color space definition and conversion, a rich set of display-oriented imaging operators, complex text layout, and printing.

For more information, see the Java 2D API Home Page

Demo
If you have a 1.4 Java runtime environment and the Java Web Start product installed, you can run the 1.4 Java 2D demo to see some of the capabilities of the Java 2D API.

 
Printing: Putting It on Paper

Java 2D technology includes extensive APIs for generating and sending high-quality output to printing devices. See the Java Printing home page for further information on printing on the Java platform.

 
Abstract Window Toolkit (AWT): APIs for Integrating with the Desktop

The AWT has provided the core underpinnings for Java applications since Java 1.0 was introduced. The java.awt package contains the base-level APIs that allow Java applications to interact with the native window system on each platform. These APIs include support for creating and managing windows (discrete areas on the display), getting input events on those windows, managing input focus, and rendering simple graphics.

The AWT also includes a set of simple GUI components that map directly to the native widget counterparts on the given platform. The AWT components provided are: Button, CheckBox, Choice(combobox), List, TextField, TextArea(no styled text), Label, Scrollbar, and ScrollPane. Because the implementation of these components rely on native widget code, they cannot be easily extended and sometimes behave inconsistently across platforms. For this reason, it is generally recommended to use the Swing UI components instead.

 
Drag and Drop: Accelerating Data Transfer

The java.awt.dnd and java.awt.datatransfer packages provide APIs for implementing Java applications with drag and drop capabilities. Drag and drop is a widely accepted (and expected) paradigm for communicating or transferring data within or between applications. The drag and drop API interfaces with the native drag and drop protocol on the given platform to enable this feature between Java and native applications, as well as across or within Java applications.

By default, both the AWT and Swing GUI components support drag and drop capabilities in standard ways. The drag and drop API provides a mechanism for developers to either extend the way drag and drop is supported in the existing components, or implement custom drag and drop behavior in the app. Applications using the standard GUI component set should not need to use the API at all, it just works.

For information on how to use drag and drop with Swing components in release 1.4 and later, see the Swing Data Transfer section of the release notes. You can also check out the original Drag and Drop specification, which is part of JavaBeans technology.

 
Accessibility: Supporting People with Disabilities

The Accessibility API included javax.accessibility package in the J2SE platform provides a clean interface that enables assistive technologies to interact and communicate with JFC and AWT components. Assistive technologies are for people with and without disabilities and include screen readers, screen magnifiers, and speech recognition. Development of this API has followed an open design process based on input from experts in the assistive technology field.

The unparalleled accessibility built into the JFC software makes it possible for software vendors to satisfy a large and growing need in government, state, and commercial markets. As a result, applications developed using JFC software will help customers meet federal regulations on accessibility, making these applications more attractive to a larger number of important market segments.

For more information on accessibility, browse the online accessibility documentation.

 
Internationalization: Supporting Users World-Wide

All of the JFC technologies in the J2SE platform are fully internationalized, so developers can easily build applications that can interact with users around the world using the user's own language and cultural conventions. Information on internationalization can be found in the J2SE V1.4 Internationalization Guide.

 
Input Method Framework: Accepting Text Input from Eastern Languages

The input method framework enables the collaboration between text editing components and input methods for entering text. Input methods are software components that let the user enter text in ways other than simple typing on a keyboard. They are commonly used to enter Japanese, Chinese, or Korean-languages using thousands of different characters-on keyboards with far fewer keys. For more details, see the Input Method Framework Guide.




Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.